Moving around quickly in Bash and Cocoa applications
The following information is probably old hat to some people, but can save you an incredible amount of time if you haven't already been exposed to it. The Bash shell allows you to use a subset of emacs or vi commands to get around in the shell. We're going to only cover the relevant Emacs commands here since vi is evil and makes me break out in hives.
Any Cocoa text editor will also use the key shortcuts that only involve the Control key for editing, so the shortcuts can get you a lot of mileage on a Mac OS X box.
Emacs uses the Control and Escape keys as key modifiers, with the interesting twist that the Control key should be held down and the modifier key struck while the Control key is depressed, while the Escape key (what the emacs people like to call the 'meta' key) should be hit and let go, then hit the modifier key. There's probably some reason for this buried in the mists of time. Presumably.
So without further ado, some good shortcuts to consign to muscle memory in order to become Lord of the Ping:
- Control-A: Go to beginning of line
- Control-E: Go to end of line
- Control-K: Cut to end of line
- Control-Y: Paste what you cut
- Control-T: Transpose letters
- Control-R: Search history backward. See below for more on this command
- Escape-F: Forward one word
- Escape-B: Backward one word
- Escape-Delete: Delete one word backward
- Escape-Control-H: Delete one word forward
Search history backward deserves some more explanation: Once you type Control-R, the prompt changes to (reverse-i-search). This is Emacs user-friendliness. At this prompt, start typing the string you're looking for, and the shell will search backward as you type. To search for more instances of the same search string, hit Control-R again.
Posted by Nic Lindh at May 29, 2004 01:32 PM
| TrackBack


