summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjohannst <johannes.stoelp@gmail.com>2021-01-06 23:38:23 +0100
committerjohannst <johannes.stoelp@gmail.com>2021-01-06 23:38:23 +0100
commit56183a201950625ad80ddaeefe70e47d0f1a900c (patch)
tree89edc8b6ac6356176e217e225a462157be1c5f6d
parent8c64543e3366413f2d830bf263ff0dfbd8482146 (diff)
downloaddotfiles-56183a201950625ad80ddaeefe70e47d0f1a900c.tar.gz
dotfiles-56183a201950625ad80ddaeefe70e47d0f1a900c.zip
zshrc add kill function to only delete parts of paths
-rw-r--r--zshrc15
1 files changed, 14 insertions, 1 deletions
diff --git a/zshrc b/zshrc
index 41cdad0..694f7d7 100644
--- a/zshrc
+++ b/zshrc
@@ -143,10 +143,22 @@ bindkey -- "$key[Down]" down-line-or-beginning-search
# Emacs mode
+# Backward delete word without treating '/' as part of a word. Convenient when deleting paths.
+function emacs-backward-kill-word() {
+ # WORDCHARS
+ # A list of non-alphanumeric characters considered part of a word by the line editor.
+
+ # Remove '/' from WORDCHARS
+ local WORDCHARS=${WORDCHARS/\//}
+ zle backward-kill-word
+}
+zle -N emacs-backward-kill-word
+
+bindkey -M emacs "$key[CtrlLeft]" backward-word
bindkey -M emacs "$key[AltLeft]" backward-word
bindkey -M emacs "$key[CtrlRight]" forward-word
bindkey -M emacs "$key[AltRight]" forward-word
-bindkey -M emacs "$key[CtrlBackspace]" backward-kill-word
+bindkey -M emacs "$key[CtrlBackspace]" emacs-backward-kill-word
# Vi mode
@@ -168,6 +180,7 @@ bindkey -M viins "$key[CtrlS]" history-incremental-search-forward
bindkey -M viins "$key[CtrlW]" backward-kill-word
bindkey -M viins "$key[Backspace]" backward-delete-char
+bindkey -M viins "$key[CtrlBackspace]" emacs-backward-kill-word
# Dirstack