diff options
author | Starfall <us@starfall.systems> | 2021-10-06 20:07:18 -0500 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2021-10-06 20:10:54 -0500 |
commit | 4b389e7edc4c5457cb87cf4c7ab42483f386cb68 (patch) | |
tree | 309c6d8f57f82e558c27e5772faef463e4e3b1d7 /.config | |
parent | 948dd9523f5370e7a9d233d849a4ebf51a1f7ed1 (diff) |
zsh: move completions, history, and vi mode to their own files
Diffstat (limited to '.config')
-rw-r--r-- | .config/zsh/.zshrc | 50 | ||||
-rw-r--r-- | .config/zsh/completions.zsh | 17 | ||||
-rw-r--r-- | .config/zsh/history.zsh | 9 | ||||
-rw-r--r-- | .config/zsh/vi-mode.zsh | 18 |
4 files changed, 47 insertions, 47 deletions
diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 396eec9..b95a0ca 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -13,53 +13,6 @@ export CDPATH=".:$HOME:$HOME/devil:$HOME/src" # just enables a bit nicer life when copy/pasting commands from docs setopt interactive_comments -# completions -setopt complete_in_word # complete both ends of words -setopt always_to_end # and move cursor to the end afterward -setopt auto_menu # <tab><tab> brings up the menu ... -setopt no_menu_complete # ... and does not select the first option -setopt auto_param_slash # convenience: add trailing / after directories -setopt no_case_glob -setopt no_flow_control -# complete . and .. -zstyle ':completion:*' special-dirs true -# complete the middle of words e.g. lc -> pluralcafe -zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*' -# cache completions -zstyle ':completion::complete:*' use-cache yes -zstyle ':completion::complete:*' cache-path "$HOME/.zcompcache" -# enable completions -autoload -Uz compinit && compinit - -# history -HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history -HISTSIZE=10000 -SAVEHIST=$HISTSIZE -setopt extended_history # write timestamp -setopt inc_append_history # write always, not just at end of session -setopt hist_ignore_space # add leading space to hide from history -setopt hist_ignore_dups # deduplicate commands run twice in a row -setopt hist_verify # confirm before executing - -# vi mode -bindkey -v -# make backspace and delete behave like vim -bindkey -M viins '^?' backward-delete-char -bindkey -M viins '^H' backward-delete-char -bindkey -M viins '^[[3~' delete-char -# display block cursor in normal mode -function zle-keymap-select zle-line-init zle-line-finish { - case $KEYMAP in - vicmd) echo -ne "\e[2 q";; - viins|main) echo -ne "\e[6 q";; - esac - zle reset-prompt - zle -R -} -zle -N zle-keymap-select -zle -N zle-line-init -zle -N zle-line-finish - # colors in various core utils alias diff='diff --color' export LESS='-R' @@ -108,6 +61,9 @@ function spacetotab () { mv "$1.tmp" "$1" } +source $ZDOTDIR/completions.zsh +source $ZDOTDIR/history.zsh +source $ZDOTDIR/vi-mode.zsh source $ZDOTDIR/prompt.zsh # display a fortune when opening an interactive terminal diff --git a/.config/zsh/completions.zsh b/.config/zsh/completions.zsh new file mode 100644 index 0000000..bbaacba --- /dev/null +++ b/.config/zsh/completions.zsh @@ -0,0 +1,17 @@ +# completions +setopt complete_in_word # complete both ends of words +setopt always_to_end # and move cursor to the end afterward +setopt auto_menu # <tab><tab> brings up the menu ... +setopt no_menu_complete # ... and does not select the first option +setopt auto_param_slash # convenience: add trailing / after directories +setopt no_case_glob +setopt no_flow_control +# complete . and .. +zstyle ':completion:*' special-dirs true +# complete the middle of words e.g. lc -> pluralcafe +zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*' +# cache completions +zstyle ':completion::complete:*' use-cache yes +zstyle ':completion::complete:*' cache-path "$HOME/.zcompcache" +# enable completions +autoload -Uz compinit && compinit diff --git a/.config/zsh/history.zsh b/.config/zsh/history.zsh new file mode 100644 index 0000000..3bbe525 --- /dev/null +++ b/.config/zsh/history.zsh @@ -0,0 +1,9 @@ +# history +HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history +HISTSIZE=10000 +SAVEHIST=$HISTSIZE +setopt extended_history # write timestamp +setopt inc_append_history # write always, not just at end of session +setopt hist_ignore_space # add leading space to hide from history +setopt hist_ignore_dups # deduplicate commands run twice in a row +setopt hist_verify # confirm before executing diff --git a/.config/zsh/vi-mode.zsh b/.config/zsh/vi-mode.zsh new file mode 100644 index 0000000..f0529f9 --- /dev/null +++ b/.config/zsh/vi-mode.zsh @@ -0,0 +1,18 @@ +# vi mode +bindkey -v +# make backspace and delete behave like vim +bindkey -M viins '^?' backward-delete-char +bindkey -M viins '^H' backward-delete-char +bindkey -M viins '^[[3~' delete-char +# display block cursor in normal mode +function zle-keymap-select zle-line-init zle-line-finish { + case $KEYMAP in + vicmd) echo -ne "\e[2 q";; + viins|main) echo -ne "\e[6 q";; + esac + zle reset-prompt + zle -R +} +zle -N zle-keymap-select +zle -N zle-line-init +zle -N zle-line-finish |