# s = combine multiple lines of whitespace into 1 # x4 = set the tabstop to 4 instead of 8 # F = Exit if the output fits on 1 screen. This is similar to git diff # R = Raw control chars. This allows you to pipe colordiff straight to less. ie: alias sdi="svn diff | colordiff | less" # S = Chop off long lines # X = Dont send termcap init and deinit scrings to the terminal
You can put this into your shell sourced file like .bashrc or .zshrc to have a different mysql prompt. See http://dev.mysql.com/doc/refman/5.1/de/mysql-commands.html for more informations. Beware that currently with mysql 5.5 the seconds are buggy and won't be displayed if you put this into a .cnf file. With the enironment variable this will work. Show Sample Output
Credit goes here: http://blag.xkcd.com/2008/12/03/some-lists/ Show Sample Output
greps using only ascii, skipping the overhead of matching UTF chars. Some stats: $ export LANG=C; time grep -c Quit /var/log/mysqld.log 7432 real 0m0.191s user 0m0.112s sys 0m0.079s $ export LANG=en_US.UTF-8; time grep -c Quit /var/log/mysqld.log 7432 real 0m13.462s user 0m9.485s sys 0m3.977s Try strace-ing grep with and without LANG=C
Renames all the jpg files as their timestamps with ".jpg" extension. Show Sample Output
Variation of the theme, this one blinks in low profile on top level of X, ie, it is visible, indeed small. Try changing fonts and sizes of osd_cat
already described on the other two versions, this one uses ascii characters on game style to display elapsed time. Show Sample Output
If a command returns a error code, you will know Show Sample Output
This function is used to sort selected lines of a text file to the end of that file. Especially useful in cases where human intervention is necessary to sort out parts of a file. Let's say that you have a text file which contains the words rough slimy red fluff dough For whatever reason, you want to sort all words rhyming with 'tough' to the bottom of the file, and all words denoting colors to the top, while keeping the order of the rest of the file intact. '$EDITOR' will open, showing all of the lines in the given file, numbered with '0' padding. Adding a '~' to the beginning of the line will cause the line to sort to the end of the file, adding '!' will cause it to sort to the beginning. Show Sample Output
In some case, you need to use remote gui on servers or simple machines and it's boring to see "cannot open display on ..." if you forgot to export your display. Juste add this line in .bashrc on remote machine. Dont forget to allow remote client on your local X server :
xhost +
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
I used to do a lot of path manipulation to set up my development environment (PATH, LD_LIBRARY_PATH, etc), and one part of my environment wasn't always aware of what the rest of the environment needed in the path. Thus resetting the entire PATH variable wasn't an option; modifying it made sense.
The original version of the functions used sed, which turned out to be really slow when called many times from my bashrc, and it could take up to 10 seconds to login. Switching to parameter substitution sped things up significantly.
The commands here don't clean up the path when they are done (so e.g. the path gets cluttered with colons). But the code is easy to read for a one-liner.
The full function looks like this:
remove_path() {
eval PATHVAL=":\$$1:"
PATHVAL=${PATHVAL//:$2:/:} # remove $2 from $PATHVAL
PATHVAL=${PATHVAL//::/:} # remove any double colons left over
PATHVAL=${PATHVAL#:} # remove colons from the beginning of $PATHVAL
PATHVAL=${PATHVAL%:} # remove colons from the end of $PATHVAL
export $1="$PATHVAL"
}
append_path() {
remove_path "$1" "$2"
eval PATHVAL="\$$1"
export $1="${PATHVAL}:$2"
}
prepend_path() {
remove_path "$1" "$2"
eval PATHVAL="\$$1"
export $1="$2:${PATHVAL}"
}
I tried using regexes to make this into a cleaner one-liner, but remove_path ended up being cryptic and not working as well:
rp() { eval "[[ ::\$$1:: =~ ^:+($2:)?((.*):$2:)?(.*):+$ ]]"; export $1=${BASH_REMATCH[3]}:${BASH_REMATCH[4]}; };
Show Sample Output
usage: dng BRE [selection] default selection is the last match DNS is ok, but although domainnames may be easier to remember than IP numbers, it still requires typing them out. This can be error-prone. Even more so than typing IPv4 numbers, depending on the domainname, its length and complexity.
(This may be specific to bash only.) This transforms the current working directory to all uppercase characters and replaces forward slashes with backslashes, prepending the string with "C:" and appending a single ">". It serves no practical purpose, but may serve as a great practical joke if you can insert it to some victim's .bashrc :-) Show Sample Output
If there are spaces won't work.
This will check if a user is logged in using ssh and will log out the user automatically after the specified time in seconds without data retrieval on the server side. Will work with bash and zsh so put it into your sourced shell file on the server side. Be aware that users can change this themselves as it's just a envoronment variable. Show Sample Output
hide your ass, buddy.
just an alternative to setting the size, this allows you to scroll up and see your previous commands in a given session but when you logout the history is not saved. That's the only advantage to doing it this way.. Show Sample Output
Use it as bash-script. The first positional parameter specifies the fixed length of the numerical index. Further params specify the files to manipulate.
This exports all lines of input file as environment variables, assuming each line is like these: OH=YEAH FU=UUUU
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: