From a29ce0aabf193eaa35b7f42a6be13a3a15ab8dff Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 10 Feb 2020 21:07:00 +0100 Subject: [PATCH] Improve zsh vi-mode handling Moved mode indicator to more immediately visible prompt location. Allowed deletions and adding spaces regardless of mode. Allow moving backwards through history and searching through terminal input history. --- zsh/.config/zsh/.p10k._zsh | 2 +- zsh/.config/zsh/.zshrc | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/zsh/.config/zsh/.p10k._zsh b/zsh/.config/zsh/.p10k._zsh index a1422a8..ddaab13 100644 --- a/zsh/.config/zsh/.p10k._zsh +++ b/zsh/.config/zsh/.p10k._zsh @@ -39,6 +39,7 @@ typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( # =========================[ Line #1 ]========================= # os_icon # os identifier + vi_mode # vi mode (you don't need this if you've enabled prompt_char) dir # current directory # =========================[ Line #2 ]========================= newline @@ -87,7 +88,6 @@ vim_shell # vim shell indicator (:sh) midnight_commander # midnight commander shell (https://midnight-commander.org/) nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) - vi_mode # vi mode (you don't need this if you've enabled prompt_char) # vpn_ip # virtual private network indicator # load # CPU load # disk_usage # disk usage diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index 127d395..01a0b1d 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -105,6 +105,29 @@ bindkey " " globalias bindkey "^ " magic-space # control-space to bypass completion bindkey -M isearch " " magic-space # normal space during searches +# VIM MODE for the shell +# enable vim mode on pressing escape +bindkey -v +# remove the delay for switching modes +export KEYTIMEOUT=1 +# space puts a space, even in cmd mode +bindkey -a ' ' magic-space +# always allow backspace/delete to remove letters +bindkey '^?' backward-delete-char +bindkey -a '^?' backward-delete-char +bindkey '^h' backward-delete-char +bindkey -a '^h' backward-delete-char +# and forward with delete +bindkey '^[[3~' delete-char +bindkey -a '^[[3~' delete-char +# always allow removing words with +bindkey -a '^w' backward-kill-word +# enable cycling through previous commands with +bindkey '^P' up-line-or-history +bindkey '^N' down-line-or-history +# search history backwards +bindkey '^r' history-incremental-search-backward + # Deduplicate PATH - remove any duplicate entries from PATH # from: https://unix.stackexchange.com/questions/40749/remove-duplicate-path-entries-with-awk-command get_var() {