This commit is contained in:
eneller
2021-11-18 00:04:08 +01:00
commit 9fc8cd56b1

151
.zshrc Normal file
View File

@@ -0,0 +1,151 @@
#OPTIONS SECTION
#unsetopt beep # try disabling annoying beep sounds
setopt nobeep
xset b off
autoload -Uz compinit # load completion
compinit
_comp_options+=(globdots) # Include hidden files.
setopt autocd # allow cd by only entering directory without cd command
setopt extendedglob # Extended globbing. Allows using regular expressions with *
setopt correct # Auto correct mistakes
setopt numericglobsort # Sort filenames numerically when it makes sense
setopt appendhistory # Immediately append history instead of overwriting
HISTFILE=~/.history
zstyle ':completion:*' special-dirs true # complete hidden directories
zstyle ':completion:*' special-files true # complete hidden files
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # Case insensitive tab completion
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" # Colored completion (different colors for dirs/files/etc)
zstyle ':completion:*' menu select # enable navigable menu for completion
zstyle ':completion:*' rehash true # Automatically update PATH entries
zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' # Smart matching of dashed values, e.g. f-b matching foo-bar
zstyle ':completion:*' group-name '' # Group results by category
zstyle ':completion:*' insert-tab false # Don't insert a literal tab when trying to complete in an empty buffer
zstyle ':completion:*' completer _complete _ignored _correct _approximate # Enable approximate completions
zstyle ':completion:*' verbose true # Verbose completion results
#zstyle ':completion:*' show-completer true
#zstyle ':completion:*' matcher-list 'r:|[._-'\''"`´,;:]=** r:|=**'
#zstyle ':completion:*' original true
#zstyle :compinstall filename '/home/en/.zshrc'
# Show message while waiting for completion
# Pretty messages during pagination
zstyle ':completion:*' list-prompt '%SAt %p: Hit TAB for more, or the character to insert%s'
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
# Nicer format for completion messages
#zstyle ':completion:*:descriptions' format '%U%B%d%b%u' #shows categories of commands like "built-in" and "external"
#zstyle ':completion:*:corrections' format '%U%F{green}%d (errors: %e)%f%u'
#zstyle ':completion:*:warnings' format '%F{202}%BSorry, no matches for: %F{214}%d%b'
# Prettier completion for processes
#zstyle ':completion:*:*:*:*:processes' force-list always
zstyle ':completion:*:*:*:*:processes' menu yes select
zstyle ':completion:*:*:*:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,args -w -w"
autoload -Uz bracketed-paste-magic # allow links to be read without escaping
zle -N bracketed-paste bracketed-paste-magic
autoload -Uz url-quote-magic
zle -N self-insert url-quote-magic
WORDCHARS=${WORDCHARS//\/[&.;]} # Don't consider certain characters part of the word
#ALIAS SECTION
alias ls='ls -hN --group-directories-first --color=auto' # make output more readable and show directories first
alias grep='grep --color=auto' # colorize grep output, set GREP_COLORS
alias cp="cp -i" # Confirm before overwriting something
alias df='df -h' # Human-readable sizes
alias free='free -m'
alias vi='nvim' # Show sizes in MB
# Add an "alert" alias for long running commands. Use like so: 'sleep 10; alert'
alias notify='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
#Add a "dotfiles" alias for .dotfile git repo
alias dotfiles='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
#KEYBINDINGS SECTION (use 'cat -v' or 'od -c' to see raw keyboard output)
bindkey -e # use emacs key layout
bindkey '^[[1;5D' backward-word # 'CTRL + leftarrow'
bindkey '^[[1;5C' forward-word # 'CTRL + rightarrow'
bindkey '^H' backward-kill-word # delete previous word with ctrl+backspace
bindkey '^[[3~' delete-char # enable delete key
bindkey '^[[3;5~' kill-word # 'CTRL + DEL'
bindkey '^Z' undo # 'CTRL + z' undo last action
#PLUGIN SECTION
if [[ -x /usr/lib/command-not-found ]] ; then # try loading suggestions to install when command was not found
function command_not_found_handler() {
/usr/lib/command-not-found --no-failure-msg -- $1
}
fi
source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme # load theme
#source /usr/share/doc/find-the-command/ftc.zsh quiet # load command not found, might need `systemctl enable pacman-files.timer`
#source /usr/share/zsh/plugins/zsh-background-notify/bgnotify.plugin.zsh # load notifications for long comands, customize message?
#bgnotify_threshold=4
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh # load syntax highlighting, everything except autosuggestions should be loaded before this
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)
ZSH_HIGHLIGHT_STYLES[default]=none
#ZSH_HIGHLIGHT_STYLES[reserved-word]=fg=009,standout
#ZSH_HIGHLIGHT_STYLES[alias]=fg=white,bold
#ZSH_HIGHLIGHT_STYLES[builtin]=fg=white,bold
#ZSH_HIGHLIGHT_STYLES[function]=fg=white,bold
#ZSH_HIGHLIGHT_STYLES[command]=fg=white,bold
ZSH_HIGHLIGHT_STYLES[precommand]=fg=#eaff00,bold
#ZSH_HIGHLIGHT_STYLES[commandseparator]=none
#ZSH_HIGHLIGHT_STYLES[hashed-command]=fg=009
#ZSH_HIGHLIGHT_STYLES[path]=fg=214,underline
#ZSH_HIGHLIGHT_STYLES[globbing]=fg=063
#ZSH_HIGHLIGHT_STYLES[history-expansion]=fg=white,underline
#ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=none
#ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=none
#ZSH_HIGHLIGHT_STYLES[back-quoted-argument]=none
#ZSH_HIGHLIGHT_STYLES[single-quoted-argument]=fg=063
#ZSH_HIGHLIGHT_STYLES[double-quoted-argument]=fg=063
#ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]=fg=009
#ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]=fg=009
#ZSH_HIGHLIGHT_STYLES[assign]=none
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh # load fish-completion, needs to be sourced after syntax highlighting
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#737373,bg=translucent"
#random stuff
#zstyle ':completion:*' completer _complete _ignored _correct _approximate
#zstyle ':completion:*' matcher-list 'r:|[._-'\''"`´,;:]=** r:|=**'
#zstyle ':completion:*' original true
#zstyle :compinstall filename '/home/en/.zshrc'
#if [[ -f ~/.dircolors ]] ; then
# eval $(dircolors -b ~/.dircolors)
#elif [[ -f /etc/DIR_COLORS ]] ; then
# eval $(dircolors -b /etc/DIR_COLORS)
#fi