Place the argument of the most recent command on the shell

'ALT+.' or '<ESC> .'
When typing out long arguments, such as: cp file.txt /var/www/wp-content/uploads/2009/03/ You can put that argument on your command line by holding down the ALT key and pressing the period '.' or by pressing <ESC> then the period '.'. For example: cd 'ALT+.' would put '/var/www/wp-content/uploads/2009/03/ as my argument. Keeping pressing 'ALT+.' to cycle through arguments of your commands starting from most recent to oldest. This can save a ton of typing.

317
By: atoponce
2009-03-20 11:36:04

8 Alternatives + Submit Alt

What Others Think

Doesn't seem to work for me, they both just re-input what I just typed -- from the same line.
ozymandias · 495 weeks and 4 days ago
@mpb Except that I don't require the use of the shift modifier. Further, comments don't get as high attention as a newly submitted command. @ozymandias If your previous command didn't have an argument, then it will just place the previous command on the line.
atoponce · 495 weeks and 4 days ago
atoponce -- that's what I tested...
ozymandias · 494 weeks and 4 days ago
Only 'ESC+.' works for me.
bwoodacre · 489 weeks and 6 days ago
Make sure you're holding Alt while pressing period. If you press . again it will go back in history too. If only Esc . works for you, you need to set your terminal to send meta as escape.
rkulla · 440 weeks ago
Only Escape + . works for me in Terminal on a Mac.
erikhansen · 436 weeks and 4 days ago
In Vi mode: <Esc> _ Or to choose arg and _ to activate: <Alt>+<num>, _
homburg · 393 weeks and 1 day ago
You can also use the numeric prefix to adjust the argument from the previous command which will be used. In bash, the numeric prefix is Esc (\e below) followed by any number of digits, and the modifier counts parameters from the start, with \e0\e. giving you the command itself, \e2\e. the second parameter. In zsh, the numeric prefix is extended by \e single-digit, so to pass in 12 it's \e1\e2. For \e. zsh counts backwards with 1 being the *last* parameter, so that \e. and \e1\e. are equivalent. This makes sense, since the numeric prefix is conceptually a repetition count. Except that zsh then makes \e0\. get the command position, same as bash. Still both useful. Add in on zsh: zle -N copy-earlier-word bindkey '^[,' copy-earlier-word and you have \e, to copy the previous word from the *current* command-line, and numeric prefices upon that, and the ability to mess around with long paths gets much easier.
syscomet · 330 weeks and 2 days ago
You can also use $_ in BASH. Good for scripts. :)
somaddict · 304 weeks and 4 days ago
works on my machine, running Gnome 2 on Debian.
sandcurves · 300 weeks and 3 days ago
Ok, pressing . gives me older and older commands, but what if I go too far, ans would like to cycle forward?
unixmonkey63146 · 267 weeks and 5 days ago
Can anyone help with the Vi-mode version <Esc> _ doesn't seem to work for me.
crashandburn4 · 235 weeks and 4 days ago
the ALT "." command has become one of the biggest time savers I've ever used w/the added benifit of a little less risk than using some other similar options. This, and `sudo !!` have saved me lots of time. But "." is the cats meow.
substdio · 233 weeks and 2 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: