commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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
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:
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.
There are 2 alternatives - vote for the best!
After executing a command with multiple arguments like
cp ./temp/test.sh ~/prog/ifdown.sh
you can paste any argument of the previous command to the console, like
ls -l ALT+1+.
is equivalent to
ls -l ./temp/test.sh
ALT+0+. stands for command itself ('ls' in this case)
Simple ALT+. cycles through last arguments of previous commands.
This works if your terminal is in Vi mode
If you can do better, submit your command here.
You must be signed in to comment.
hmm, remarkably similar to:
http://www.commandlinefu.com/commands/view/1545/gets-the-last-string-of-previous-command-with-
Doesn't seem to work for me, they both just re-input what I just typed -- from the same line.
@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 -- that's what I tested...
Only 'ESC+.' works for me.
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.
Only Escape + . works for me in Terminal on a Mac.
In Vi mode:
<Esc> _Or to choose arg and _ to activate:
<Alt>+<num>, _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-wordbindkey '^[,' copy-earlier-wordand 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.
You can also use $_ in BASH. Good for scripts. :)
works on my machine, running Gnome 2 on Debian.