Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I've recently immigrated from Ubuntu to Mac OSX Snow Leopard. I use the terminal (iterm2) extensively, and I am a great fan of shortcut keys.

The standard shortcut keys (which work in any GUI textbox) are:

  • + Jumps to first character in line
  • + Jumps to last character in line
  • + Moves one word forward
  • + Moves one word backward

How can I impose these shortcuts in iterm (or terminal)?

Are there any standard key bindings for these operations in Mac I should know and use?

share|improve this question
    
iTerm > Prefs > Keys lets you customize your keybindings and shortcuts. –  user588 Feb 1 '12 at 13:40
add comment

3 Answers

up vote 4 down vote accepted

The standard shell shortcuts (M- = meta = option or esc, C- = control):

  • M-b and M-f correspond to ⌥← and ⌥→
  • C-a and C-e correspond to ⌘← and ⌘→

⌥← and ⌥→ are bound to M-b and M-f by default on Lion's Terminal. On 10.6 you'll have to add them manually:

enter image description here

I haven't found any way to reassign ⌘← and ⌘→ in Terminal.

share|improve this answer
    
+1 Thanks. What does `\033b' stand for? Do you know how can I change this on iterm? –  Adam Matan Feb 1 '12 at 11:17
    
A few other useful shortcuts: C-w will kill the previous word. C-k will kill from the current cursor point to the end of the line. C-y will yank back what was previously killed. –  cm2 Feb 1 '12 at 18:00
1  
The '\033' is an escape sequence for the "escape key" on the keyboard, which is essentially the meta key that @Lri mentioned. So '\033b' is essentially M-b and '\033f' is essentially M-f. See, for example, hints.macworld.com/article.php?story=20100716230217548 –  cm2 Feb 1 '12 at 18:10
add comment

For iTerm2 you can customize hotkeys easily. A similar question was asked here

How can I move through words when typing a command in iTerm2?

share|improve this answer
add comment

You'll also find Ctl-e (end of line), Ctl-a (start of line), and Esc-d (delete word from cursor) work nicely in terminal and other apps, too (along with Ctl-k and Ctl-y mentioned above), as does repeat-letter (Esc-NNN d; Esc-22 d for example to output 22 letter d's). In fact, most of the keyboard shortcuts I've tried from other Unix distributions have worked in OS/X.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.