From 0c5f290464290b4b62a968d2b0abf06bb60d0259 Mon Sep 17 00:00:00 2001 From: saibotk Date: Fri, 16 Jun 2023 01:41:07 +0200 Subject: [PATCH] zsh: Adjust completion & fix history --- zsh/.zshrc | 64 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 9 deletions(-) diff --git a/zsh/.zshrc b/zsh/.zshrc index bee3ab9..00b9573 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -5,23 +5,69 @@ export DOTFILES=$HOME/.dotfiles zstyle ':znap:*' repos-dir ~/.znap source ~/.znap/znap/znap.zsh -# autocomplete settings -zstyle ':autocomplete:tab:*' widget-style menu-select -zstyle ':autocomplete:*' fzf-completion yes -zstyle ':autocomplete:*' min-input 2 +# shell options +setopt correct # Auto correct mistakes +setopt completealiases +setopt extendedglob # Extended globbing. Allows using regular expressions with * +setopt nocaseglob # Case insensitive globbing +setopt rcexpandparam # Array expension with parameters +setopt nocheckjobs # Don't warn about running processes when exiting +setopt numericglobsort # Sort filenames numerically when it makes sense +setopt nobeep # No beep +setopt autocd # if only directory path is entered, cd there. + +# history settings +HISTFILE="$HOME/.zsh_history" +HISTSIZE=50000 +SAVEHIST=10000 + +## History command configuration +setopt extended_history # record timestamp of command in HISTFILE +setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE +setopt hist_ignore_dups # ignore duplicated commands history list +setopt hist_ignore_space # ignore commands that start with space +setopt hist_verify # show command with history expansion to user before running it +setopt share_history # share command history data +setopt appendhistory # Immediately append history instead of overwriting +setopt inc_append_history + +# completion settings +# Amazing guide: https://thevaluable.dev/zsh-completion-guide-examples/ +setopt menu_complete +setopt nolistambiguous +ZSH_AUTOSUGGEST_STRATEGY=( history completion ) +zstyle ':completion:*' completer _extensions _complete _approximate +zstyle ':completion:*:*:*:*:descriptions' format '%F{cyan}-- %d --%f' +zstyle ':completion:*' group-name '' +zstyle ':completion:*' file-list all # Show files like ls -la +zstyle ':completion:*' menu select yes # Show completion list menu and do not ask to display even long lists +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:*' rehash true # automatically find new executables in path +# Speed up completions +zstyle ':completion:*' accept-exact '*(N)' +zstyle ':completion:*' use-cache on +zstyle ':completion:*' cache-path ~/.zsh/cache +# See https://github.com/zsh-users/zsh-autosuggestions/issues/118#issuecomment-184319846 +ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(expand-or-complete history-beginning-search-backward-end history-beginning-search-forward-end) # Plugins -znap source ohmyzsh/ohmyzsh lib/{git,theme-and-appearance} -znap source ohmyzsh/ohmyzsh plugins/{per-directory-history,git} +znap source jimhester/per-directory-history znap source marlonrichert/zcolors -znap source marlonrichert/zsh-autocomplete +znap source zsh-users/zsh-history-substring-search znap source zsh-users/zsh-autosuggestions znap source zsh-users/zsh-syntax-highlighting znap source jessarcher/zsh-artisan -znap source unixorn/fzf-zsh-plugin # Extra init code needed for zcolors. -znap eval zcolors "zcolors ${(q)LS_COLORS}" +znap eval zcolors zcolors + +# Bind history key to substring plugin +zmodload zsh/terminfo +bindkey "$terminfo[kcuu1]" history-substring-search-up +bindkey "$terminfo[kcud1]" history-substring-search-down +bindkey '^[[A' history-substring-search-up +bindkey '^[[B' history-substring-search-down # Load macos specific configs if [[ $OSTYPE == 'darwin'* ]]; then