Prepends paths containing man directories to your MANPATH variable for the given top level directory. If you build or install software with non-standard documentation locations, you can just add them to your MANPATH with this little function. -xdev prevents crossing filesystem boundaries when searching for man dirs. Show Sample Output
Define commands that you always invoke with an appended '&disown'. In the example:
gvim foo.txt
will open gvim dettached from the current terminal.
This function displays the latest comic from xkcd.com. One of the best things about xkcd is the title text when you hover over the comic, so this function also displays that after you close the comic.
To get a random xkcd comic use the following:
xkcdrandom() { wget -qO- http://dynamic.xkcd.com/comic/random | sed -n 's#^<img src="\(http://imgs.[^"]\+\)"\s\+title="\(.\+\?\)"\salt.\+$#eog "\1"\necho '"'\2'#p" | bash; }
These are just a bit shorter than the ones eigthmillion wrote, however his version didn't work as expected on my laptop for some reason (I got the title-tag first), so these build a command which is executed by bash.
"infix" version in bash (4.x+) Remove -v to make it silent. BTW: The OP forgot to use "cat" and "nmap" ;-) I had a good laugh though. Show Sample Output
even shorter (infix) version. Show Sample Output
This function uses xmllint to evaluate xpaths. Usage: xpath /some/xpath XMLfile Show Sample Output
use python as calculator, press ctrl+d to exit reminder: when doing factions add atleast one decimal number like so 22.0/7 or 22/7.0 Show Sample Output
regenerateCSR original.crt new.key new.csr
Show Sample Output
Ever done a find to get content and been messed up by .git, .svn, .hg or the like spamming your results? Did you really want to grep over every copy of the file that existed in your git history?
Replace:
grep -r PATTERN .
with:
grep PATTERN -- $(have_here)
or if you really have too many files to put in one argv:
have_here | xargs grep PATTERN --
It gives a 'xcd' command for changing directory to one of CWDs of other ZSH processes (typically running in a terminal emulator). Useful for single-windowed terminal emulators like XTerm or Rxvt which don't have ability to pass CWD of one shell to another. Show Sample Output
Support several arguments. Show Sample Output
use the shell default positional parameter syntax ${X:-default} in lieu of testing.
Put this into your ~/.bashrc to create a database for mysql with a user and password. Usage: createdb `database` `datbase-user` `database-password`.
This gets the Nth argument in the last line of your history file. This is useful where history is being written after each command, and you want to use arguments from the previous command in the current command, such as when doing copies/moving directories etc. I wrote this after getting irritated with having to continually type in long paths/arguments. You could also use $_ if all you want is the last argument. Show Sample Output
Same functionality without using bash functions. Show Sample Output
What's wrong with this? Show Sample Output
A simple bash function to the find command. I use this much more than find itself. Show Sample Output
For now just returns either "Success" or "Error". My awk-fu isn't strong enough to hackily parse out the error in case there is one, so I kept it simple. Show Sample Output
Yo run the `nohist` command and after that the commands won't get stored in the history file for the current session. This makes no permanent changes.
usage = crontest "/path/to/bin" This version of this function will echo back the entire command so it can be copied/pasted to crontab. Should be able to be automagically appended to crontab with a bit more work. Tested on bash and zsh on linux,freebsd,aix Show Sample Output
I like this method because I can make use of pgrep which also has the -f flag that can use regex to match patterns in the full command line string. It will also do ps -fww on all pids returned by pgrep, providing a list of process matching the regex provided. Show Sample Output
Prints a string as a sequence of hexadecimal values. Output comes in space separated pairs, regardless of ASCII or Unicode characters Show Sample Output
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.
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: