diff options
author | Sebastian Gniazdowski <sgniazdowski@gmail.com> | 2018-06-04 13:17:34 +0200 |
---|---|---|
committer | Peter Stephenson <p.stephenson@samsung.com> | 2018-06-05 09:38:31 +0100 |
commit | 52f1c4ffb0a7aecc89b965edc6457ee8393dee95 (patch) | |
tree | db07723ecb5a489b0f3c8981744a55b056081e5c | |
parent | d63ae0acc9ee0ad861c56e8eefbccf1d039292b0 (diff) | |
download | zsh-52f1c4ffb0a7aecc89b965edc6457ee8393dee95.tar.gz zsh-52f1c4ffb0a7aecc89b965edc6457ee8393dee95.tar.xz zsh-52f1c4ffb0a7aecc89b965edc6457ee8393dee95.zip |
42929 (tweaked): additional default bindings in zed.
Add to both zed and zed-vicmd keymaps.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Functions/Misc/zed | 31 |
2 files changed, 31 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog index 5b3f1e668..900c0b6cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-06-05 Peter Stephenson <p.stephenson@samsung.com> + + * Sebastian: 42929 (twaked): Functions/Misc/zed: additional + default bindings for emacs and vi modes. + 2018-06-03 Oliver Kiddle <okiddle@yahoo.co.uk> * 42826: Eitan Adler: Misc/bash2zshprompt: remove link to diff --git a/Functions/Misc/zed b/Functions/Misc/zed index f571daf5e..56fdef188 100644 --- a/Functions/Misc/zed +++ b/Functions/Misc/zed @@ -3,7 +3,7 @@ # # No other shell could do this. # Edit small files with the command line editor. -# Use ^X^W to save, ^C to abort. +# Use ^X^W to save (or ZZ in vicmd mode), ^C to abort. # Option -f: edit shell functions. (Also if called as fned.) setopt localoptions noksharrays @@ -60,6 +60,11 @@ __zed_pg_down() done } +if ! zle -la __zed_pg_up __zed_pg_down; then + zle -N __zed_pg_up + zle -N __zed_pg_down +fi + if (( bind )) || ! bindkey -M zed >&/dev/null; then # Make the zed keymap a copy of the current main. bindkey -N zed main @@ -75,10 +80,16 @@ if (( bind )) || ! bindkey -M zed >&/dev/null; then bindkey -M zed '^x^w' accept-line bindkey -M zed '^M' self-insert-unmeta - zle -N __zed_pg_up - zle -N __zed_pg_down - [[ ${+terminfo} = 1 && -n "$terminfo[kpp]" ]] && bindkey -M zed "$terminfo[kpp]" __zed_pg_up - [[ ${+terminfo} = 1 && -n "$terminfo[knp]" ]] && bindkey -M zed "$terminfo[knp]" __zed_pg_down + [[ ${+terminfo} = 1 ]] && { + [[ -n "$terminfo[kpp]" ]] && bindkey -M zed "$terminfo[kpp]" __zed_pg_up + [[ -n "$terminfo[knp]" ]] && bindkey -M zed "$terminfo[knp]" __zed_pg_down + [[ -n "$terminfo[khome]" ]] && bindkey -M zed "$terminfo[khome]" beginning-of-line + [[ -n "$terminfo[kend]" ]] && bindkey -M zed "$terminfo[kend]" end-of-line + + # Fallback to well known code as terminfo might be wrong (often) sometimes + bindkey -M zed "^[[H" beginning-of-line + bindkey -M zed "^[[F" end-of-line + } # Make zed-set-file-name available. # Assume it's in fpath; there's no error at this point if it isn't @@ -89,6 +100,16 @@ if (( bind )) || ! bindkey -M zed-vicmd >&/dev/null; then bindkey -N zed-vicmd vicmd bindkey -M zed-vicmd "ZZ" accept-line + [[ ${+terminfo} = 1 ]] && { + [[ -n "$terminfo[kpp]" ]] && bindkey -M zed-vicmd "$terminfo[kpp]" __zed_pg_up + [[ -n "$terminfo[knp]" ]] && bindkey -M zed-vicmd "$terminfo[knp]" __zed_pg_down + [[ -n "$terminfo[khome]" ]] && bindkey -M zed-vicmd "$terminfo[khome]" vi-beginning-of-line + [[ -n "$terminfo[kend]" ]] && bindkey -M zed-vicmd "$terminfo[kend]" vi-end-of-line + + # Fallback to well known code as terminfo might be wrong (often) sometimes + bindkey -M zed-vicmd "^[[H" vi-beginning-of-line + bindkey -M zed-vicmd "^[[F" vi-end-of-line + } fi (( bind )) && return 0 |