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.
This commit is contained in:
Marty Oehme 2020-02-10 21:07:00 +01:00
parent b76b3ca4ca
commit a29ce0aabf
No known key found for this signature in database
GPG key ID: 0CCB0526EFB9611A
2 changed files with 24 additions and 1 deletions

View file

@ -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

View file

@ -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 <c-w>
bindkey -a '^w' backward-kill-word
# enable cycling through previous commands with <c-p/n>
bindkey '^P' up-line-or-history
bindkey '^N' down-line-or-history
# search history backwards <c-r>
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() {