Forwarding Address: OS X

Sunday, April 24, 2005

bash Tricks

In my continued quest to bring the goodness of the command line to light I present to you Tony Stubblebine's bash Tricks From the Developers of the O'Reilly Network:
History

Bash keeps a history of the commands you've run. My group was already comfortable with the up and down arrows to navigate the history, !! to repeat the last command, and !foo to repeat the last command starting with foo.

Our newest admin had a better way, CTRL-R. That does command auto completion. Repeatedly pressing CTRL-R lets you tab through matching commands.

Home/End

CTRL-A takes you to the beginning of the line and CTRL-E takes you to the end of the line. This is probably basic shell knowledge, but I'm probably (hopefully) not the only person who didn't know it.

Errr... I didn't. For OS X cmd-line junkies this looks like a column to watch.

2 Comments:

  • Many of the control-key commands come from the fact that Bash uses Emacs-like line editing by default.

    To navigate the history, use ^P (control-p) to go up, ^N to go down the list. (In Emacs, those move up/down a line in the file.) ^F goes forwards one character, ^B goes back.

    ESC-f goes forward one word, ESC-b back one word. ESC-DELETE erases the previous word.

    There are more, but that's a good start.

    By Jim Menard, at 7:22 AM  

  • Those Emacs shortcuts are also good to learn because they are available in all standard Cocoa text fields.

    By pbx, at 5:56 AM  

Post a Comment

<< Home