required packages: curl, xml2, html2text command is truncated, see 'sample output' Show Sample Output
Using perl and tput, show all the colors with numbers that your actual $TERM can handle.
If want to remove the numbers at beginning of new line, it should be something like this:
perl -E 'say `tput setb $_`," "x `tput cols`, `tput sgr0` for 0 .. (`tput colors` - 1)'
This command will take the output of a command and color any STDERR output as a different color (red outline in this case) Show Sample Output
It's the same command as submitted, but first with a command to make all characters green. It's the only way it looked "matrix-like" on my gnome-terminal.
Same as above but slooooow it down
This will diff your local version of the file with the latest version in svn. I put this in a shell function like so:
svd() { vimdiff <(svn cat "$1") "$1"; }
One of the first functions programmers learn is how to print a line. This is my 100% bash builtin function to do it, which makes it as optimal as a function can be. The COLUMNS environment variable is also set by bash (including bash resetting its value when you resize your term) so its very efficient. I like pretty-output in my shells and have experimented with several ways to output a line the width of the screen using a minimal amount of code. This is like version 9,000 lol.
This function is what I use, though when using colors or other terminal features I create separate functions that call this one, since this is the lowest level type of function. It might be better named printl(), but since I use it so much it's more optimal to have the name contain less chars (both for my programming and for the internal workings).
If you do use terminal escapes this will reset to default.
tput sgr0
For implementation ideas, check my
http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html
Show Sample Output
Multi-argument version, but with VIM loveliness :D
Unlike other alternatives, this command only relies on bash builtins and should also work on windows platforms with the bash executable. Sparseness corresponds to the number 128 and can be adjusted. To print all possible digits instead of only 0 and 1 replace RANDOM%2 by RANDOM%10 or RANDOM%16 to add letters [A-F]. Show Sample Output
Colorify colors input by converting the text to a number and then performing modulo 7 on it. This resulting number is used as the color escape code. This can be used to color the results of commands with complex outputs (like "482279054165371") so if any of the digits change, there's a good chance the color will change too. I say good chance because there's only 7 unique colors here, so assuming you were watching random numbers, there would be a 6/7 chance that the color would change when the number changed. This should really only be used to help quickly identify when things change, but should not be the only thing relied upon to positively assert that an output has not changed. Show Sample Output
Another wall matrix :) Show Sample Output
I was looking for the fastest way to create a bunch of ansi escapes for use in echo -e commands throughout a lot of my shell scripts. This is what I came up with, and I actually stick that loop command in a function and then just call that at the beginning of my scripts to not clutter the environment with these escape codes, which can wreck havok on my terminal when I'm dumping the environment. More of a cool way to store escape ansi codes in an array. You can echo them like:
echo -e "${CC[15]}This text is black on bright green background."
I usually just use with a function:
# setup_colors - Adds colors to array CC for global use
# 30 - Black, 31 - Red, 32 - Green, 33 - Yellow, 34 - Blue, 35 - Magenta, 36 - Blue/Green, 37 - White, 30/42 - Black on Green '30\;42'
function setup_colors(){ declare -ax CC; for i in `seq 0 7`;do ii=$(($i+7));CC[$i]="\033[1;3${i}m";CC[$ii]="\033[0;3${i}m";done;CC[15]="\033[30;42m"; export R='\033[0;00m';export X="\033[1;37m"; };
export -f setup_colors
CC[15] has a background of bright green which is why it is separate. R resets everything, and X is my default font of bright white.
CC[15]="\033[30;42m"; R=$'\033[0;00m'; X=$'\033[1;37m'
Those are just my favorite colors that I often use in my scripts. You can test which colors by running
for i in $(seq 0 $((${#CC[@]} - 1))); do echo -e "${CC[$i]}[$i]\n$R"; done
See: http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html for more usage.
Show Sample Output
This will affect all invocations of grep, even when it is called from inside a script.
The expression $(( $RANDOM * 6 / 32767 + 1 )) generates a random number between 1 and 6, which is then inserted into the escape sequence \e[3_m to switch the foreground color of the terminal to either red, green, yellow, blue, purple or cyan. The color can be reset using the escape sequence \e[0m. The full list of colors can be found here: https://wiki.archlinux.org/index.php/Color_Bash_Prompt#List_of_colors_for_prompt_and_Bash
eg:
printTextInColorRed foo bar
foo bar [in red color]
Extract a color palette from a image useful for designers.
Example usage:
extract-palette myawesomeimage.jpg 4
Where the first argument is the image you want to extract a palette from. The second argument is the number of colors you want.
It may be the case where you want to change the search space. In that case, change the -resize argument to a bigger or smaller result. See the ImageMagick documentation for the -resize argument.
Show Sample Output
If you use colored ls(1), the broken symbolic links significantly differ from regular files and directories in the ls listing. In my case it is bright red. 0 is for getting the first place in the list.
Requires wdiff. Prints the word-by-word diff with the old version highlighted in red, and the new in green. Change the colors by altering 41m and 42m. 45m is more of a magenta and may be easier to read.
A tweak using Patola's code as a base, this full-width green matrix display has all the frills (and all the printable characters). You don't need the surrounding parens if you don't care about losing globbing capabilities. Z-shell (/bin/zsh) needs neither the parens nor the `set -o noglob` Screen shot (animated): http://desmond.imageshack.us/Himg32/scaled.php?server=32&filename=matrixh.gif&res=landing If it's too slow, try lowering the `sleep 0.05` or even replacing it with `true` (which is faster than `sleep 0`). I squashed it as narrow as I could to conserve space, though somebody could probably squeeze a char or two out. Enjoy!
save as shell script and pipe your command output Show Sample Output
Shows the ?rendering? for each of the 256 colours in both the bold and normal variant. Using seq is helpful to get even lines, passing $((COLUMNS*2)) to column sort-of-handles the nonprintable characters.
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: