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.
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:
Clears your clipboard if xsel is installed on your machine.
If your xsel is dumb, you can also use
xsel --clear --clipboard
ssh from local to remote and pipe output of file to the local clipboard
Typing a word in terminal is easier than digging your phone out, opening your two-factor authentication app and typing the code in manually.
This alias copies the one-time code to your clipboard for 3 seconds (long enough to paste it into a web form), then restores whatever was on the clipboard beforehand.
This command works on Mac. Replace pbpaste/pbcopy with your distribution's versions.
Very convenient to for sending data to the clipboard for processing.
However, note that tee will affect the buffering of the output (stdout won't be update very live).
This command takes the content of a Parcellite-managed clipboard manager and add one level of indentation to it. It may be useful to indent a block of code which will enter inside another, already indented one but I use it mostly to indent code I will post in Stack Overflow questions and answers.
Copying and pasting from Office documents open in Office:mac can dirty your files with Windows CRLF and (inexplicably) Classic Mac OS LF newlines, which can break some tools. This snippet replaces them with good ol' Unix LF newlines.
Copy the current path. Use -selection clipboard to copy the string to clipboard.
Use the excellent sensiblepasswords.com to a generate random (yet easy-to-remember) password every second, and copy it to the clipboard. Useful for generating a list of passwords and pasting them into a spreadsheet.
This script uses "madebynathan"'s "cb" function (http://madebynathan.com/2011/10/04/a-nicer-way-to-use-xclip/); you could also replace "cb" with
xclip -selection c
Remove "while true; do" and "; done" to generate and copy only 1 password.
This uses ssh to transfer the contents of one Mac's clipboard to another's. This only works with plain text, sadly. Trying to transfer images will just clear out the remote machine's clipboard, and rich text will be converted to plain text. Using the "Remote Login" must be enabled on the remote machine (via System Preferences' Sharing panel) for this to work.
Translate the X selection from German to English. The tw program is available from Savannah: http://mirror.its.uidaho.edu/pub/savannah/twandgtw/
I'm posting this because the base Debian system also does not include curl.
Uses google api to translate, you can modify the language in which translate modifying the parameter "langpair=|en", the format is language input|language output.
That works in all softs, CLI or GUI... I don't want to waste time to all the time typing the same stuff . So, I have that command in my window manager shortcuts ( meta+l ). All the window managers have editable shortcuts AFAIK. If not, or you don't want to use it that way, you can easily use the xbindkeys soft.
I you're using kde4, you can run :
then open "inputs actions" and create a new shortcut.
For Gnome take a look there : http://www.cyberciti.biz/faq/howto-create-keyboard-shortcuts-in-gnome/
A more advanced one, with strings and newlines :
xvkbd -xsendevent -text "---8<-----\nToday date is: $(date +%Y%m%d)\n---8<-----"
For complicated or long paste, you can feed xvkbd with a file :
xvkbd -xsendevent -file <file>
You can simulate ^C ( control+c ) too or others combinations of keys :
xvkbd -text "\C\Ac"
There's no man page nor help ( On my Archlinux distro ), but you can see online doc there : http://homepage3.nifty.com/tsato/xvkbd/
"Copying" things to the X clipboard doesn't normally create a copy. Rather the data to be 'copied' is referenced. This means that if the application that you 'copied' stuff from is closed, that data is lost. If the application that you 'copied' from is suspended with CTRL-Z, there could be some issues if you try to paste it into something.
This command will create a copy of referenced data and have xclip be the provider of it, so you can then go ahead and close the app that contains the original information.
Caveat: I'm not sure if this is binary-safe (though i would expect it to be), and don't know what would happen if you used it to clip a 20 meg gimp image.
This technique becomes more convenient if you set it up as an action in a clipboard manager (eg klipper, parcellite). Some of these applets can take automatic action based on a variety of parameters, so you could probably just get it to always own the clipped data whenever data is clipped.
Redirects the contents of your clipboard through a pipe, to a remote machine via SSH.
shortest alternative without the speed-o-meter"xclip large.xml"
"xclip -o" to get the clipboard content, alternatively [shift key] + insert or middle button of your mouse.
In turn you can get the contents of your clipboard by typing xsel by itself with no arguments:
This command requires you to install the xsel utility which is free