# Nice key bindings bindkey -b ^r history-search-backward bindkey -b ^w backward-delete-word bindkey -b ^u backward-kill-line bindkey -b ^b backward-word # Ctrl + b bindkey -b ^f forward-word # Ctrl + f bindkey '^[OD' backward-word # Ctrl + Left bindkey '^[OC' forward-word # Ctrl + Right bindkey '\e[1;5D' backward-word # ~ for xterm bindkey '\e[1;5C' forward-word # ~
How to obtain the key sequence from a function key, or combination of keys: use the read command.
Example for pressing Ctrl + Left sequence:
$ read ^[[1;5DExample for pressing Esc sequence:
$ read ^[
Make sure you write the key sequence as \e[1;5D rather than ^[[1;5D. The ^[ sequence is equivalent to the [Esc] key, which is represented by \e in the shell. So, for instance, if the key sequence was ^[[OP the resulting bind code to use would be \e[OP.
The same key sequence for a function key or combination can be obtained by pressing Ctrl+V and then the key or sequence.
Thanks. This helped.
ReplyDelete