When I open a terminal and type
asdf asdf asdf asdf
And hit control-u
, the line gets wiped. If I type that line again, but then use option-left
to skip a word back, then control-u
doesn't wipe the line at all.
To begin with I was having trouble with option-right
not skipping words forward. So I thought I fixed it with these terminal settings. But honestly I have no idea what these ascii codes do, and what state my terminal gets into.
Do ascii codes that skip words forward and back without breaking the terminal exist? What are they?
FYI Looking at set -o
I see that VI mode is off.
macbookpro% set -o | grep ' on'
combiningchars on
interactive on
login on
shinstdin on
Best Answer
I found a lot of clues here: https://coderwall.com/p/a8uxma/zsh-iterm2-osx-shortcuts
This is what I put in my
.zshrc
to fix things.Alongside these terminal keyboard settings:
For some reason, the control (^) key modifier can be set, but does not activate the codes in the terminal. So I'm only using option and shift.
I found a similar solution here which mentioned you can see the key codes by running
cat
. https://stackoverflow.com/questions/12382499/looking-for-altleftarrowkey-solution-in-zshInitially I used whatever key codes I wanted. That was a mistake, because even though they worked on my local mac, they didn't work when I SSH-ed into a linux machine. Using
less /etc/inputrc
on the remote bash I found these existing shortcuts:Also, my local bash had different settings. To find those out I used
Which made me settle on the terminal keyboard settings you see at the top. Because they worked in all 3 settings (local zsh, local bash, remote bash).