I'm looking for a keyboard shortcut in tcsh
to move the cursor back to the previous blank: not ESC+B which takes me back one word (for instance, in a path argument, to the previous path component) – I want to get to previous space or start of current path.
Tcsh shortcut to move the cursor back to previous space
keyboard shortcutsline-editortcsh
Best Answer
If you mean keyboard shortcut at the prompt of interactive
bash
shells, you could bind theshell-backward-word
andshell-forward-word
to some sequence of characters sent upon some key or combination of key presses.Like if pressing Ctrl-Left sends the sequence
\e[1;5D
on your terminal like it does inxterm
, you could do:Note that it does not jump from blank to blank but considers shell quoting. So for instance in a line like
It would jump to the locations marked above.
Edit: for
tcsh
, you have three options:Use the equivalent to the
bash
definition above, either in~/.cshrc
or in/etc/csh.cshrc.local
to give all users the benefit.Use the
vi
mode (withbindkey -v
) and use theB
andW
keys in normal mode just like invi
.In
emacs
mode (the default, reenabled withbindkey -e
) like forbash
, bind the corresponding widgets (vi-word-back
andvi-word-fwd
):Note that those are like
vi
'sB
andW
, so they're for jumping between blank separated words, not shell tokens (like quoted strings) like in thebash
solution above.