diff options
-rw-r--r-- | .config/zsh/aliases.zsh | 20 | ||||
-rw-r--r-- | .config/zsh/completion.zsh | 86 | ||||
-rw-r--r-- | .config/zsh/help_command.zsh | 2 | ||||
-rw-r--r-- | .config/zsh/history_search.zsh | 15 | ||||
-rw-r--r-- | .config/zsh/key_bindings.zsh | 55 | ||||
-rw-r--r-- | .config/zsh/zsh_history | 12 | ||||
-rw-r--r-- | .zshenv | 10 | ||||
-rw-r--r-- | .zshrc | 13 |
8 files changed, 213 insertions, 0 deletions
diff --git a/.config/zsh/aliases.zsh b/.config/zsh/aliases.zsh new file mode 100644 index 0000000..deabea3 --- /dev/null +++ b/.config/zsh/aliases.zsh @@ -0,0 +1,20 @@ +alias vim='nvim' +alias diff='diff --color=auto' +alias grep='grep --color=auto' +alias ip='ip --color=auto' +alias ls='ls --color=auto' +alias mv='mv -iv' +alias cp='cp -riv' +alias rm='rm -ir' +alias mkdir='mkdir -vp' +alias less='/usr/share/nvim/runtime/macros/less.sh' +alias config='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME' + +export LESS=-R +export LESS_TERMCAP_mb=$'\E[1;31m' # begin blink +export LESS_TERMCAP_md=$'\E[1;36m' # begin bold +export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink +export LESS_TERMCAP_so=$'\E[01;44;33m' # begin reverse video +export LESS_TERMCAP_se=$'\E[0m' # reset reverse video +export LESS_TERMCAP_us=$'\E[1;32m' # begin underline +export LESS_TERMCAP_ue=$'\E[0m' # reset underline diff --git a/.config/zsh/completion.zsh b/.config/zsh/completion.zsh new file mode 100644 index 0000000..c850087 --- /dev/null +++ b/.config/zsh/completion.zsh @@ -0,0 +1,86 @@ +# From https://wiki.archlinux.org/index.php/Zsh + +### Handle command not found +if [ -e /usr/share/doc/pkgfile/command-not-found.zsh ]; then + source /usr/share/doc/pkgfile/command-not-found.zsh +else + echo "pkgfile not installed" +fi + +### For autocompletion with an arrow-key driven interface +zstyle ':completion:*' menu select + +### For autocompletion of command line switches for aliases +setopt complete_aliases + +### For enabling autocompletion of privileged environments in privileged commands +zstyle ':completion::complete:*' gain-privileges 1 + +### Use cache +zstyle ':completion:*' use-cache on +zstyle ':completion:*' cache-path ~/.cache/zsh/cache + +### Prevent CVS files/directories from being completed +zstyle ':completion:*:(all-|)files' ignored-patterns '(|*/)CVS' +zstyle ':completion:*:cd:*' ignored-patterns '(*/)#CVS' + +### Fuzzy matching of completions for when you mistype them +zstyle ':completion:*' completer _complete _correct _match _approximate +zstyle ':completion:*:match:*' original only +zstyle ':completion:*:approximate:*' max-errors 1 numeric + +### The number of errors allowed by _approximate to increase with the length of what you have typed so far +zstyle -e ':completion:*:approximate:*' \ + max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)' + +### Ignore completion functions for commands you don't have +zstyle ':completion:*:functions' ignored-patterns '_*' + +### With helper functions +xdvi() { command xdvi ${*:-*.dvi(om[1])} } + +### you can avoid having to complete at all in many cases, but if you do, you might want to fall into menu selection immediately andto have the words sorted by time: +zstyle ':completion:*:*:xdvi:*' menu yes select +zstyle ':completion:*:*:xdvi:*' file-sort time + +### Completing process IDs with menu selection +zstyle ':completion:*:*:kill:*' menu yes select +zstyle ':completion:*:kill:*' force-list always +zstyle ':completion:*:processes' command 'ps -A -o pid,user,comm -w -w' + +### If you end up using a directory as argument, this will remove the trailing slash +zstyle ':completion:*' squeeze-slashes true + +### cd will never select the parent directory +zstyle ':completion:*:cd:*' ignore-parents parent pwd + +### cd without cd +setopt auto_cd + +### Quick change directories +rationalise-dot() { + if [[ $LBUFFER = *.. ]]; then + LBUFFER+=/.. + else + LBUFFER+=. + fi +} +zle -N rationalise-dot +bindkey . rationalise-dot + +### Complete from middle of filename +zstyle ':completion:*' matcher-list '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' '+l:|=* r:|=*' + +### auto rehash +zstyle ':completion:*' rehash true + +### add colors +zstyle ':completion:*' menu select list-colors ${(s.:.)LS_COLORS} + +### completion and prompt init +autoload -Uz compinit promptinit colors vcs_info +compinit +promptinit + +### This will set the default prompt to the walters theme +prompt walters diff --git a/.config/zsh/help_command.zsh b/.config/zsh/help_command.zsh new file mode 100644 index 0000000..91f2892 --- /dev/null +++ b/.config/zsh/help_command.zsh @@ -0,0 +1,2 @@ +autoload -Uz run-help +alias help=run-help diff --git a/.config/zsh/history_search.zsh b/.config/zsh/history_search.zsh new file mode 100644 index 0000000..5a0c3d7 --- /dev/null +++ b/.config/zsh/history_search.zsh @@ -0,0 +1,15 @@ +# History search +HISTFILE=~/.cache/zsh/zsh_history +HISTSIZE=90000 +SAVEHIST=90000 +setopt appendhistory + +autoload -Uz up-line-or-beginning-search down-line-or-beginning-search +zle -N up-line-or-beginning-search +zle -N down-line-or-beginning-search + +[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-beginning-search +[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-beginning-search + +## Do not write duplicate events to history +# setopt HIST_SAVE_NO_DUPS diff --git a/.config/zsh/key_bindings.zsh b/.config/zsh/key_bindings.zsh new file mode 100644 index 0000000..acfd24c --- /dev/null +++ b/.config/zsh/key_bindings.zsh @@ -0,0 +1,55 @@ +# Key bindings + +## create a zkbd compatible hash; to add other keys to this hash, see: man 5 terminfo +typeset -g -A key + +key[Home]="${terminfo[khome]}" +key[End]="${terminfo[kend]}" +key[Insert]="${terminfo[kich1]}" +key[Backspace]="${terminfo[kbs]}" +key[Delete]="${terminfo[kdch1]}" +key[Up]="${terminfo[kcuu1]}" +key[Down]="${terminfo[kcud1]}" +key[Left]="${terminfo[kcub1]}" +key[Right]="${terminfo[kcuf1]}" +key[PageUp]="${terminfo[kpp]}" +key[PageDown]="${terminfo[knp]}" +key[Shift-Tab]="${terminfo[kcbt]}" + +## setup key accordingly +[[ -n "${key[Home]}" ]] && bindkey -- "${key[Home]}" beginning-of-line +[[ -n "${key[End]}" ]] && bindkey -- "${key[End]}" end-of-line +[[ -n "${key[Insert]}" ]] && bindkey -- "${key[Insert]}" overwrite-mode +[[ -n "${key[Backspace]}" ]] && bindkey -- "${key[Backspace]}" backward-delete-char +[[ -n "${key[Delete]}" ]] && bindkey -- "${key[Delete]}" delete-char +[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-history +[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-history +[[ -n "${key[Left]}" ]] && bindkey -- "${key[Left]}" backward-char +[[ -n "${key[Right]}" ]] && bindkey -- "${key[Right]}" forward-char +[[ -n "${key[PageUp]}" ]] && bindkey -- "${key[PageUp]}" beginning-of-buffer-or-history +[[ -n "${key[PageDown]}" ]] && bindkey -- "${key[PageDown]}" end-of-buffer-or-history +[[ -n "${key[Shift-Tab]}" ]] && bindkey -- "${key[Shift-Tab]}" reverse-menu-complete + +## Finally, make sure the terminal is in application mode, when zle is active. Only then are the values from $terminfo valid. +if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then + autoload -Uz add-zle-hook-widget + function zle_application_mode_start { echoti smkx } + function zle_application_mode_stop { echoti rmkx } + add-zle-hook-widget -Uz zle-line-init zle_application_mode_start + add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop +fi + +## Shift, Alt, Ctrl and Meta modifiers + +key[Control-Left]="${terminfo[kLFT5]}" +key[Control-Right]="${terminfo[kRIT5]}" + +[[ -n "${key[Control-Left]}" ]] && bindkey -- "${key[Control-Left]}" backward-word +[[ -n "${key[Control-Right]}" ]] && bindkey -- "${key[Control-Right]}" forward-word + +## Vim mapping for completion +zmodload zsh/complist +bindkey -M menuselect 'h' vi-backward-char +bindkey -M menuselect 'k' vi-up-line-or-history +bindkey -M menuselect 'l' vi-forward-char +bindkey -M menuselect 'j' vi-down-line-or-history diff --git a/.config/zsh/zsh_history b/.config/zsh/zsh_history new file mode 100644 index 0000000..8f53a20 --- /dev/null +++ b/.config/zsh/zsh_history @@ -0,0 +1,12 @@ +ls +ls +history +cd .config/zsh +ls +rm -fr zsh_history +ls +cd .config/zsh +ls +source ~/.zshrc +vim history_search.zsh +sudo poweroff @@ -0,0 +1,10 @@ +typeset -U PATH path +path=("$HOME/.local/bin" "$path[@]") +export PATH + +export EDITOR=/usr/bin/nvim +export PAGER="/usr/bin/nvim -u NORC +Man!" +export MANPAGER="/usr/bin/nvim -u NORC +Man!" +export VISUAL=/usr/bin/nvim +export BROWSER=/usr/bin/firefox +export QT_QPA_PLATFORMTHEME=qt5ct @@ -0,0 +1,13 @@ +# Created by newuser for 5.8 + +## Use vim mode +bindkey -v +export KEYTIMEOUT=1 + +## Source other configs +### key_bindings should be before completion due to complist +source $HOME/.config/zsh/key_bindings.zsh +source $HOME/.config/zsh/completion.zsh +source $HOME/.config/zsh/history_search.zsh +source $HOME/.config/zsh/aliases.zsh +source $HOME/.config/zsh/help_command.zsh |