diff --git a/config/zsh/.zshrc b/config/zsh/.zshrc index 7dd652c..6a4470e 100644 --- a/config/zsh/.zshrc +++ b/config/zsh/.zshrc @@ -5,19 +5,78 @@ source ${ZDOTDIR:-$HOME}/.antidote/antidote.zsh antidote load ${ZDOTDIR:-$HOME}/zsh_plugins.txt +autoload -U colors && colors + # To customize prompt, run `p10k configure` or edit ~/.config/zsh/.p10k.zsh. [[ ! -f ~/.config/zsh/.p10k.zsh ]] || source ~/.config/zsh/.p10k.zsh ## autoload -U compinit -compinit -C zstyle ':completion:*' menu select +zmodload zsh/complist +compinit -C +_comp_options+=(globdots) # Include hidden files + +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 setopt appendhistory setopt hist_ignore_all_dups +bindkey -v +export KEYTIMEOUT=1 + +# Edit line in $EDITOR with c-e +autoload edit-command-line +zle -N edit-command-line +bindkey '^e' edit-command-line + + + + +# Change cursor shape for different vi modes. +function zle-keymap-select { + if [[ ${KEYMAP} == vicmd ]] || + [[ $1 = 'block' ]]; then + echo -ne '\e[1 q' + elif [[ ${KEYMAP} == main ]] || + [[ ${KEYMAP} == viins ]] || + [[ ${KEYMAP} = '' ]] || + [[ $1 = 'beam' ]]; then + echo -ne '\e[5 q' + fi +} +zle -N zle-keymap-select +zle-line-init() { + zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere) + echo -ne "\e[5 q" +} +zle -N zle-line-init +echo -ne '\e[5 q' # Use beam shape cursor on startup. +preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt. + + +# Use lf to switch directories and bind it to ctrl-o +lfcd () { + tmp="$(mktemp)" + lf -last-dir-path="$tmp" "$@" + if [ -f "$tmp" ]; then + dir="$(cat "$tmp")" + rm -f "$tmp" + [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" + fi +} +bindkey -s '^o' 'lfcd\n' + + + + + + bindkey '^[[A' history-substring-search-up # or '\eOA' bindkey '^[[B' history-substring-search-down # or '\eOB' HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE=1 diff --git a/config/zsh/zsh_plugins.txt b/config/zsh/zsh_plugins.txt index 8f3c553..2f3ab4a 100644 --- a/config/zsh/zsh_plugins.txt +++ b/config/zsh/zsh_plugins.txt @@ -1,7 +1,8 @@ romkatv/powerlevel10k -zsh-users/zsh-autosuggestions zsh-users/zsh-syntax-highlighting zsh-users/zsh-history-substring-search joshskidmore/zsh-fzf-history-search + +MichaelAquilina/zsh-you-should-use