17

I am using the word split style shell (select-word-style shell). I like it in general but would like to split at forward slashes also, so that when I go forward/backward a word, if the word doesn't contain any /s, it completely skips over the word but if it does contain one or more slashes, it stops at the first slash.

Any ideas?

1 Answer 1

27

man zshall /forward-word /backward-word

echo $WORDCHARS
*?_-.[]~=/&;!#$%^(){}<>
WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'  ;# without /
8
  • 6
    +1 I wonder why this is not the default. Paths are probably the single most used entity in a command line. Sep 19, 2012 at 10:51
  • 1
    A more succinct version is WORDCHARS=${WORDCHARS//[\/]}. Sep 19, 2012 at 14:24
  • 4
    even shorter WORDCHARS=${WORDCHARS/\/} Sep 19, 2012 at 14:44
  • 2
    or WORDCHARS=$WORDCHARS:s:/: Nov 17, 2012 at 21:39
  • 1
    This works in the default configuration, but the question assumes select-word-style shell, and that ignores $WORDCHARS. Aug 20, 2021 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.