Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This happens to me all the time: I type a long command line and forget to specify some options. For example:

$ tcpdump host foo.com and port 8080

Hmm, I should be seeing some output. Ah! Forgot to listen on a different interface.

At this point I'd hit the up-arrow to bring back the previous command, then either scroll back to the first argument or press C-a to jump to the start of the command and scroll forward to the first argument.

Is there a quicker way to jump to the first argument so I can insert the -i eth1 option?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

I believe the closest shortcut without key rebindings is CTRL-A, ALT-F (ESC-F in Mac).

share|improve this answer

Command line editing can be done using either emacs style commands or vi style commands. The default is emacs (See Jin's answer).

If you are more used to vi than emacs you can switch this editing mode in your ~/.bashrc file by adding set -o vi Then you can use any vi commands you are familiar with

Esc, 0, e, a (start of line, end of word, append)
Alt+0, w, i (start of line, next word, insert)
Alt+5, B, i (go back 5 words, insert)
Alt+F, h, i (find "h" going backwards, insert).
etc.

share|improve this answer

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.