Skip to content

Bash Emacs Mode

Navigating the command line on Apple’s terminal can be frustrating. The arrow keys only allow you to move one character at a time. So if you have typed a long command, say:

$ perl texWordCount.pl /Users/markkalderon/Documents/TheHub/Research/Metamerism/Drafts/metamerism.tex

and you realize you have forgotten an option, in this case -T:

$ perl -T texWordCount.pl /Users/markkalderon/Documents/TheHub/Research/Metamerism/Drafts/metamerism.tex

it can be tedious to move to the beginning of the line, character by character, to insert it. Fortunately, bash, the default shell on OS X, has an emacs mode allowing you to use a subset of emacs commands on the command line. Emacs uses two modifier keys—control and meta. On OS X control is ⌃ and meta is ⎋.

Command Action
ctrl-a Move cursor to beginning of line
ctrl-e Move cursor to end of line
meta-b Move cursor back one word
meta-f Move cursor forward one word
ctrl-w Cut the last word
ctrl-u Cut everything before the cursor
ctrl-k Cut everything after the cursor
ctrl-y Paste the last thing to be cut
ctrl-_ Undo

{ 1 } Trackback

  1. […] a previous post I discussed bash emacs mode—a convenient way to get around the bash command line quicker. […]

Post a Comment

You must be logged in to post a comment.
FireStats icon Powered by FireStats