I just switched from bash to zsh on my arch linux install and want to change my keybinding so that ctrl + arrow skips a word forward/backward. If I add

bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word

it works for the current session, but once I restart my terminal I have to redo this. Could anyone tell me how I can save my keybindings in zsh?

  • Add these lines to the end of ~/.zshrc. – jimmij Jun 11 '16 at 16:34

As a rule, shells just execute the commmands they're given, they don't automatically save their state. It's common to have different state in different shell instances (e.g. settings depending on the current directory). While it isn't very common to have different sets of key bindings, it can be useful (for example with different keyboards when accessing the same machine from different devices).

The principle of command line shells is that what you type on a command line can equivalently be placed into a script file. So if you know how to do something by typing a command line, you know how to make it automatic: put it in a script file. To apply a setting to all shell sessions, put it in the shell's startup file. For interactive zsh sessions, that's ~/.zshrc, i.e. the file called .zshrc in your home directory.

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.