Never leave the home row in bash
To edit a command in bash you often need to jump around in the line and revert to using the arrow keys. As a vim/emacs user this becomes a bit of a clumsy non-ergonomic movement, here are some shortcuts to help you keep your fingers on the home row. If you are an emacs user these are going to look familiar.
-
ctrl-p
- previous command entered -
ctrl-n
- next command entered -
ctrl-a
- jump to BOL -
ctrl-e
- jump to EOL -
alt-b
- jump word forward -
alt-f
- jump word backwards -
alt-b
- jump character forward -
alt-f
- jump character backwards
If these shortcuts don't work try running set -o emacs
Alternatively you can turn on vi mode in your shell by calling set -o vi
, which you can add to your .zshrc
or add set editing-mode vi
to your .inputrc
. After setting this you can enter normal mode by hitting escape and use vi motions to edit/move.
Your shell just got upgraded. 💪💻
Tweet