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:
It find out the mic recording level at the moment of run the command and if a noise level is higher it starts to record an mp3 file. The resulting file will have only the sounds not the silences.
Copy changed files from remote git repository, _including binary ones_, staged and unstaged alike. Note that this command doesn't handle deleted files properly.
this command will add the following two lines into the ~/.bash_aliases:
alias exit='pwd > ~/.lastdir;exit'
[ -n "$(cat .lastdir 2>/dev/null)" ] && cd "$(cat .lastdir)"
or redirect it to the ~/.bashrc if you like
Donno, I find it usefull. You may also define an alias for 'cd ~' like - alias cdh='cd ~'
don't bother spawning a bc process or counting the number of options, just pick a random one.
'sort -R' sorts randomly, so pick the top one.
Generates a bash array and uses it to select a random image from ~/wallpapers.
SImply type "cd" and press enter
Usage: ytmp3 "YTurl" "YTurl2" "YTurl3" "YTurlN"
Uses the shift command to let you extract the .mp3 from as many youtube urls as you like (or wherever else youtube-dl is supported)
Orginal chunk of code:
youtube-dl -q -t --extract-audio --audio-format mp3 URL
This is usefull to diff 2 paths in branches of software, or in different versions of a same zip file. So you can get the real file diff.
NOTE: When doing these commands when asked for questions there might be flowing text from the pv doing the progress bar just continue typing as if its not there, close your eyes if it helps, there might be a yes or no question, type "yes" and ENTER to it, and also it will ask for a password, just put in your password and ENTER
I talk alot more about this and alot of other variations of this command on my site:
Creates a git repository in a predefined location.
git gc should be run on all git repositories every 100 commits. This will help do do so if you have many git repositories ;-)
if you cd into a directory then cd into another directory somewhere else then you run the cd - command you will go to the previous directory you was in!! To go back to the other directory just run it again. So if you are working in 2 different directories then this is the perfect command for you.
Install Ksuperkey one command in Kubuntu.
You must manually add ksuperkey to autostart in System Settings KDE.
In order to unrar several files in different subfolders, you just need to launch this command in your parent folder in order to have your files ready for manipulation and already extracted;
I did not put anything to delete the original rar files
I did not like two things in the submitted commands and fixed it here:
1) If I do cd - afterwards, I want to go back to the directory I've been before
2) If I call up without argument, I expect to go up one level
It is sad, that I need eval (at least in bash), but I think it's safe here.
eval is required, because in bash brace expansion happens before variable substitution, see http://rosettacode.org/wiki/Repeat_a_string#Using_printf
Here's an alternative if you don't have seq.
You can also remove the "&& pwd" if you don't want it to print out each directory as it moves up.
Assumes you've cd'd to the folder in which all your git repos reside; you could run it from ~ without -maxdepth, although that might make find take quite a while longer.
If you have several processor cores, but not that much ram, you might want to run
git config --global pack.threads 1
first, since gc-ing can eat lots of ram.