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.

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 · 669 weeks and 5 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 · 669 weeks and 5 days ago
atoponce -- that's what I tested...
ozymandias · 668 weeks and 5 days ago
Only 'ESC+.' works for me.
bwoodacre · 664 weeks 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 · 614 weeks ago
Only Escape + . works for me in Terminal on a Mac.
erikhansen · 610 weeks and 5 days ago
In Vi mode: <Esc> _ Or to choose arg and _ to activate: <Alt>+<num>, _
homburg · 567 weeks and 2 days 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 · 504 weeks and 3 days ago
You can also use $_ in BASH. Good for scripts. :)
somaddict · 478 weeks and 5 days ago
works on my machine, running Gnome 2 on Debian.
sandcurves · 474 weeks and 4 days ago
Ok, pressing . gives me older and older commands, but what if I go too far, ans would like to cycle forward?
unixmonkey63146 · 441 weeks and 6 days ago
Can anyone help with the Vi-mode version <Esc> _ doesn't seem to work for me.
crashandburn4 · 409 weeks and 5 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 · 407 weeks and 3 days ago
Thanks for sharing excellent informations. Your web-site is very cool. I’m impressed by the details that you have on this site tetris
Lisa1812 · 72 weeks and 5 days ago
I am happy that this website is useful for everyone. play pokemon emerald rom
JackHenry8899 · 54 weeks and 1 day ago
Toto Site Sports Toto Safety Playground Boatman Slot Site Overseas Soccer Sports Broadcast Gold Lotto 1st Prize Supernova Gambling Myanmar Protest Landers Internet Toto Site Big Casino Our Casino Site Graph Site Recommendation Toto Site Rolling
totosite40 · 28 weeks and 1 day ago
Great command. useful on arguments. affordable dog grooming in modesto
mark21 · 9 weeks and 5 days ago
seofox · 8 weeks and 4 days ago
You delivered such an impressive piece to read, giving every subject enlightenment for us to gain information. Thanks for sharing such information with us due to which my several concepts have been cleared. ???????
toto808 · 6 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? 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.


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: