Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking for ALT+LeftArrowKey solution in zsh

Tags:

shell

key

zsh

I just recently switched from bash to zsh, however I miss my Alt+LeftArrowKey and Alt+RightArrowKey to go back and forth a word at a time.

Right now, if I press Alt+LeftArrowKey I go back a couple of letters and then I'm stuck. I won't go any further backwards and it won't back to the end of the line with Alt+RightArrowKey as I would expect. I can't even use the arrow keys to go to the end of the line, only to the second to last. Can't input new chars on the line either or indeed delete.

How do I get my beloved shortcut back?

I'm on Mac OS X using Terminal if that's important.

like image 233
Mads Ohm Larsen Avatar asked Oct 14 '22 19:10

Mads Ohm Larsen


People also ask

How to clear line zsh?

This helped! I use zsh (without oh-my-zsh), and I can confirm ctrl-u deletes the whole line.

How do I select in zsh?

Zsh Shift Select Mode. Emacs shift-select mode for Zsh – select text in the command line using Shift as in many text editors, browsers and other GUI programs. This plugin does not override any existing widgets and binds only shifted keys (see Key Bindings).


1 Answers

Run cat then press keys to see the codes your shortcut send.
(Press Ctrl+C to kill the cat when you're done.)
For me, (ubuntu, konsole, xterm) pressing Alt+ sends ^[[1;3D, so i would put in my .zshrc

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

(Actually I prefer to use Ctrl + arrow to move word by word, like in a normal textbox under windows or linux gui.)

Related question: Fix key settings (Home/End/Insert/Delete) in .zshrc when running Zsh in Terminator Terminal Emulator

like image 391
lolesque Avatar answered Oct 16 '22 07:10

lolesque