From 56183a201950625ad80ddaeefe70e47d0f1a900c Mon Sep 17 00:00:00 2001 From: johannst Date: Wed, 6 Jan 2021 23:38:23 +0100 Subject: zshrc add kill function to only delete parts of paths --- zshrc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'zshrc') 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 -- cgit v1.2.3