I’ve been irritated by this for quite a while, I’m surprised it took me this long to “fix”…
In bash there are two keyboard shortcuts that generally work by default on most linux systems: control-left and control-right, mapped to movement by word. For some reason on mac os x (at least for me), the default mappings in the terminal program don’t line up well with the default shell (bash). Hitting ctrl-left or ctrl-right emits a nice annoying beep because of weird characters sent to bash. I want those keys to operate the same way as they do in a linux bash prompt, and it turns out it’s pretty easy:
In terminal, open preferences, and go to the settings tab. Click on the profile you use, and then the “Keyboard” subtab. There you will see the two entries causing the problem: “control cursor left” => “33[5D” and “control cursor right” => “33[5C”. If you change them so that they are “control cursor left” => “33b” and “control cursor right” => “33f”, you’ll get much nicer behavior. At least I think so.
sheboingo!
{ 6 comments… read them below or add one }
I think you’re my new hero… For some reason I kept engaging in this stupid behaviour: I would bring up an old command that I had typed in wrong into the terminal and go back one character at a time to the spot I needed to fix. Every time I said to myself. “I know there’s a better way, I really need to look that up”. I had a significant amount of time to think about it too as I slowly crawled backwards towards my typo.
Thanks Matt!
So funny — that’s exactly what I did. Tolerated the frustration for literally years! And it was so easy to change, I’m kicking myself for not having done it sooner…
You Rock. To all people that, like us, tolerated the behaviour for years and years, thinking that, well, tomorrow I’ll look it up and fix it: unlearn the ESC+b and ESC+f “shortcuts”, change the preferences and be done with it! Next time I’m in , remind you to get you a beer.
Another vote for hero status… as a recent Linux to Mac convert, this was driving me BATTY. Until I found this post, that is.
Must be a n00b mistake, but I’m getting the literal text inserted into the shell http://grab.by/6gEq
I have this working using Alt + F and Alt + B by enabling ‘Use option as meta key’, but would prefer to use the arrows.
update on the last post, got it working with these more verbose instructions, cheers for the tip!
http://notes.timeghost.net/2010/01/option-arrow-cursor-movement-in-terminal.html