Turn shell tracing and verbosity (set -xv) on/off in any Bourne-type shell If either -x or -v is set, the function turns them both off. If neither is on, both are turned on.
Running this command turns shell tracing and shell verbose debugging on or off. Not only does it do that, it also uses your terminals builtin method of setting colors to make debugging much easier.
It looks at the current shell options contained in the $- special bash variable and that lets this function set the opposite of the current value. So from the shell you could do a:
setx; echo "y" | ( cat -t ) | echo "d"; setx
and it will turn on debbuggin.
This is an amazingly useful function that is perfect to add system-wide by adding it to /etc/profile or /etc/bashrc.. You can run it from the shell, and you can also use it in your shell scripts like my .bash_profile - http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html
Show Sample Output
Pros: Works in all Windows computers, most updated and compatible command. Cons: 3 liner Replace fcisolutions.com with your site name.
Normally the bash builtin command 'set' displays all vars and functions. This just shows the vars. Useful if you want to see different output then env or declare or export.
Alias 'sete' shows sets variables
alias sete='set|sed -n "/^`declare -F|sed -n "s/^declare -f \(.*\)/\1 ()/p;q"`/q;p"'
Alias setf shows the functions.
alias setf='set|sed -n "/^`declare -F|sed -n "s/^declare -f \(.*\)/\1 ()/p;q"`/,\$p"'
Also see: http://www.commandlinefu.com/commands/view/6899/print-all-environment-variables-including-hidden-ones
At the very least, some cool sed commands!
From my .bash_profile http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html
Show Sample Output
Move efficiently between directories.
.
This command adds a couple of extra features to cd, without affecting normal use.
CDPATH use is also unaffected. It introduces and environment variable CDDIR which is used as an alternate home directory.
.
Note: I don't want to alter $HOME because then all my dot files will move.
.
Examples:
.
cd dir
Change directory to "dir" (using CDPATH if necessary)
.
cd dir/file.txt
Change directory to "dir" (containing folder of "file.txt")
This allows you to cut'n'paste, or use
.
CDDIR is unset
cd
Change directory to $HOME
.
CDDIR=/home/flatcap/work
cd
Change directory to /home/flatcap/work
.
For convenience, put the command, and the following, in your .bashrc or .bash_profile
export CDDIR="/home/flatcap/work"
alias cdd="CDDIR=$(pwd)"
Show Sample Output
Enable tracing and print a timestamp before the command to be invoked. Original author: Peter Eisentraut http://petereisentraut.blogspot.com/2012/07/tracing-shell-scripts-with-time-stamps.html Show Sample Output
Useful if localhost is a small machine running BusyBox, which uses a slightly unusual format to set the date. Remotehost can be pretty much any Linux machine, including one running BusyBox. Uses UTC for portability.
Normally executing 'set' returns a vast amount of information, including the source code of every function and variable within the environment - including those that are part of the shell. By using the -o posix argument, bash runs temporarily in POSIX mode for this command, which simplifies expressions and leaves out the shell's own functions and definitions - leaving a much smaller, more useful list. Show Sample Output
If you need to fix a randomly failing test (race condition), you need to run it until you get that hard-to-reproduce failure. 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: