Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Textmate-like Keyboard Navigation for the Command Line?

How do I better navigate the command line? In TextMate, I can do:

  • CMD + ALT + ARROW to switch tabs

  • CMD + SHIFT + ARROW to highlight lines of text

  • ALT + SHIFT + ARROW to highlight words

  • ALT + ARROW to jump words, etc.

How do I do this kind of stuff in the terminal?

like image 702
Lance Avatar asked Mar 11 '11 19:03

Lance


2 Answers

Here's a slightly more complete mapping from Mac text navigation to the default Readline keys: iTerm key mapping

I set this up in the Keys pane of my iTerm2 preferences, but you should be able to make the same mappings in Terminal.app (Edit: Everything except the first two. Terminal.app only lets you pick from a few different keys)

like image 147
Evan Krall Avatar answered Oct 06 '22 02:10

Evan Krall


In MacOS' Terminal app, you can change your keyboard bindings; go to Terminal Preferences (shortcut Cmd + ,) and navigate to the 'Keyboard' tab:

Key => Action
control cursor left => \033b
control cursor right => \033f

etc. You can do the same thing with other emacs-style bindings. As far as switching tabs, that's a System Preferences > Keyboard > Keyboard Shortcuts setting; click 'Application Shortcuts' on the left side, and then click + on the right to add a new shortcut. Use your desired keyboard combo and pair it with the exact menu name, which in Terminal for moving forward/backward through tabs is 'Select Next Tab' and 'Select Previous Tab' (via the Window menu in Terminal), respectively.

Does that help?

like image 37
mway Avatar answered Oct 06 '22 00:10

mway