Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Modify Zsh Configuration to Make M-backspace Remove Last Path Component



Thank you!
This was exactly what I was looking for!

Am Sat, 11 Feb 2017 17:01:31 +0100
schrieb Julien Jehannet <julien@xxxxxxxx>:

> You can change the WORDCHARS setting by removing slash character:
> 
> WORDCHARS=${WORDCHARS:s@/@}
> 
> 2017-02-11 16:26 GMT+01:00 Markus Zeindl <su_ld@xxxxxxxxxxx>:
> 
> > Hello Zsh-Community,
> >
> > I've started using zsh on GNU/Linux recently.
> > When editing commands on the prompt (assumingly in the zle), I
> > sometimes want to remove the last path component of an entered path
> > descriptor, i.e. remove the basename of a path. The following
> > description considers "M" to be the alt-key (or meta-key as in
> > emacs key notation)
> >
> > Intuitively, I type M-backspace. This removes the whole path.
> > Scenario 1 illustrates this.
> >
> > Scenario 1: Target: Change directory to /foo/bar/oof/rab
> > Step 1: type target incorrectly as "% cd /foo/bar/oof/ran"
> > Step 2: press M-backspace leading to a command-line of "% cd"
> > Step 3: type target again completely leading to "%
> > cd /foo/bar/oof/rab"
> >
> > I'm not familiar with Zsh Key notation at all. So, I'm not sure,
> > what zle-command (or widget?) will be triggered on M-backspace
> > using the key mapping in Mapping 1. Is it "backward-kill-word"?
> >
> > Mapping 1: Output of "% bindkey"
> > "^@" set-mark-command
> > "^A" beginning-of-line
> > "^B" backward-char
> > "^D" delete-char-or-list
> > "^E" end-of-line
> > "^F" forward-char
> > "^G" send-break
> > "^H" backward-delete-char
> > "^I" expand-or-complete
> > "^J" accept-line
> > "^K" kill-line
> > "^L" clear-screen
> > "^M" accept-line
> > "^N" down-line-or-history
> > "^O" accept-line-and-down-history
> > "^P" up-line-or-history
> > "^Q" push-line
> > "^R" history-incremental-search-backward
> > "^S" history-incremental-search-forward
> > "^T" transpose-chars
> > "^U" kill-whole-line
> > "^V" quoted-insert
> > "^W" backward-kill-word
> > "^X^B" vi-match-bracket
> > "^X^F" vi-find-next-char
> > "^X^J" vi-join
> > "^X^K" kill-buffer
> > "^X^N" infer-next-history
> > "^X^O" overwrite-mode
> > "^X^U" undo
> > "^X^V" vi-cmd-mode
> > "^X^X" exchange-point-and-mark
> > "^X*" expand-word
> > "^X=" what-cursor-position
> > "^XG" list-expand
> > "^Xg" list-expand
> > "^Xr" history-incremental-search-backward
> > "^Xs" history-incremental-search-forward
> > "^Xu" undo
> > "^Y" yank
> > "^[^D" list-choices
> > "^[^G" send-break
> > "^[^H" backward-kill-word
> > "^[^I" self-insert-unmeta
> > "^[^J" self-insert-unmeta
> > "^[^L" clear-screen
> > "^[^M" self-insert-unmeta
> > "^[^_" copy-prev-word
> > "^[ " expand-history
> > "^[!" expand-history
> > "^[\"" quote-region
> > "^[\$" spell-word
> > "^['" quote-line
> > "^[-" neg-argument
> > "^[." insert-last-word
> > "^[0" digit-argument
> > "^[1" digit-argument
> > "^[2" digit-argument
> > "^[3" digit-argument
> > "^[4" digit-argument
> > "^[5" digit-argument
> > "^[6" digit-argument
> > "^[7" digit-argument
> > "^[8" digit-argument
> > "^[9" digit-argument
> > "^[<" beginning-of-buffer-or-history
> > "^[>" end-of-buffer-or-history
> > "^[?" which-command
> > "^[A" accept-and-hold
> > "^[B" backward-word
> > "^[C" capitalize-word
> > "^[D" kill-word
> > "^[F" forward-word
> > "^[G" get-line
> > "^[H" run-help
> > "^[L" down-case-word
> > "^[N" history-search-forward
> > "^[OA" up-line-or-history
> > "^[OB" down-line-or-history
> > "^[OC" forward-char
> > "^[OD" backward-char
> > "^[OF" end-of-line
> > "^[OH" beginning-of-line
> > "^[P" history-search-backward
> > "^[Q" push-line
> > "^[S" spell-word
> > "^[T" transpose-words
> > "^[U" up-case-word
> > "^[W" copy-region-as-kill
> > "^[[2~" overwrite-mode
> > "^[[3~" delete-char
> > "^[[A" up-line-or-history
> > "^[[B" down-line-or-history
> > "^[[C" forward-char
> > "^[[D" backward-char
> > "^[_" insert-last-word
> > "^[a" accept-and-hold
> > "^[b" backward-word
> > "^[c" capitalize-word
> > "^[d" kill-word
> > "^[f" forward-word
> > "^[g" get-line
> > "^[h" run-help
> > "^[l" down-case-word
> > "^[n" history-search-forward
> > "^[p" history-search-backward
> > "^[q" push-line
> > "^[s" spell-word
> > "^[t" transpose-words
> > "^[u" up-case-word
> > "^[w" copy-region-as-kill
> > "^[x" execute-named-cmd
> > "^[y" yank-pop
> > "^[z" execute-last-named-cmd
> > "^[|" vi-goto-column
> > "^[^?" backward-kill-word
> > "^_" undo
> > " " magic-space
> > "!"-";" self-insert
> > ";5C" emacs-forward-word
> > ";5D" emacs-backward-word
> > "<"-"~" self-insert
> > "^?" backward-delete-char
> > "\M-^@"-"\M-." self-insert
> > "\M-/" complete-word
> > "\M-0"-"\M-^?" self-insert
> >
> > How can I modify my configuration to achieve Scenario 2?
> >
> > Scenario 2: Target: Change directory to /foo/bar/oof/rab
> > Step 1: type target incorrectly as "% cd /foo/bar/oof/ran"
> > Step 2: press M-backspace leading to a command-line of
> > "% cd /foo/bar/oof/"
> > Step 3: type only last path component "rab" again leading to
> > "cd /foo/bar/oof/rab"
> >
> > Thanks a lot for every answer, helping me to improve my
> > Zsh-experience.
> >
> > All The Best,
> > Markus
> >
> 
> 
> 



Messages sorted by: Reverse Date, Date, Thread, Author