SHARE: |
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
██ ██
█▌ - FUN ON THE TERMINAL PART 8 - █▌
█▌ GET COLORIZED █▌
█ ▐▌
█ NOTE: ▐▌
█ Not in color when the examples shown are in color?: Read HERE. ▐▌
█ ▐▌
█ ___________..___________ ▐▌
█ ▐▌
█ DISPLAY TERMINAL'S COLORS ▐▌
█ VIM 256 COLOR TEST ▐▌
█ CHANGE EMAC'S COLOR THEME ▐▌
█ ▐▌
█ LOLCAT - OUTPUT COLORIZED TEXT ▐▌
█ SUPERCAT - SYNTAX COLORIZING ▐▌
█ MORE MORE MORE ▐▌
█ ▐▌
█ ___________..___________ ▐▌
█ ▐▌
█ DISPLAY TERMINAL'S COLORS: ▐▌
█ `````````````````````````` ▐▌
█ There are many scripts to demonstrate and display your terminal's colors' ▐▌
█ capabilities. Note that the colors are also dependent on the client's ▐▌
█ settings you use to connect to your shell. You run the script, it outputs ▐▌
█ the colors in the style stated within the script/program, that's it. ▐▌
█ ▐▌
█ ▐▌
█ I've come across many so I packed them all (45, little OTT again) for you ▐▌
█ to select your favorite/s (view HERE for the list). ▐▌
█ ▐▌
█ wget http://mewbies.com/geek_fun_files/color_scripts/color_scripts.tar.gz ▐▌
█ tar xvfz color_scripts.tar.gz && cd color_scripts && chmod 755 * && ls ▐▌
█ The files in color_scripts output with color codes. ▐▌
█ The files in patterns output with patterns only. ▐▌
█ Run the scripts: ./scriptname ▐▌
█ colortest.sh run with -w to fit window better: ./colortest.sh -w ▐▌
█ Where I found each file: cat README | less ▐▌
█ ▐▌
█ Included is a template I made from pfh's script so you can just paste in ▐▌
█ your own design with the correct corresponding codes. ▐▌
█ You could run it on your MOTD. ▐▌
█ ▐▌
█ You could make it available system wide, for example: ▐▌
█ 1. Edit the shebang line and save changes: ▐▌
█ pico script.sh ▐▌
█ Has this: ▐▌
█ #!/bin/bash ▐▌
█ ▐▌
█ Change to: ▐▌
█ #!/usr/bin/env /bin/bash ▐▌
█ ▐▌
█ 2. su ▐▌
█ cp script.sh /usr/local/bin/script ▐▌
█ chmod +x /usr/local/bin/script ▐▌
█ exit ▐▌
█ ▐▌
█ Test it: script ▐▌
█ ▐▌
█ ANOTHER 256 COLOR TEST: ▐▌
█ A great tput command line to display your terminals 256 colors from ▐▌
█ commandline.fu by AskApache, copy/paste both lines into your terminal: ▐▌
( x=`tput op` y=`printf %$((${COLUMNS}-6))s`;for i in {0..256};do o=00$i;\
echo -e ${o:${#o}-3:3} `tput setaf $i;tput setab $i`${y// /=}$x;done; )
█ ▐▌
█ Save the code to a file, for example: 256_aacolors.sh, paste code in, save.▐▌
█ chmod 755 aacolors.sh && ./aacolors.sh ▐▌
█ ▐▌
█ NOTE - 256 COLORS NOT SHOWING: ▐▌
█ If any of the 256 color test only showed a few colors (8-16), try this: ▐▌
█ echo $TERM ▐▌
█ If the reply was xterm, do this (valid this session only): ▐▌
█ export TERM=xterm-256color ▐▌
█ Then run the test again. To make that permanent add the line to the end ▐▌
█ of your ~/.bashrc ▐▌
█ ▐▌
█ NOTE - ESCAPE CODE MISSING: ▐▌
█ If you copy/paste a script containing an 'ESC' code sometimes that code is ▐▌
█ not pasted, or in some cases the post containing the ESC code didn't have ▐▌
█ it. You will have an error when running the script. ▐▌
█ For example it may look like this: esc="ESC" ▐▌
█ If it looks like: esc=" or esc=" " ▐▌
█ Then replace it with: esc="^[" (Do not replace with letters: ESC) ▐▌
█ Btw Notepad++ for Win handles .sh files properly. ▐▌
█ ▐▌
█ ___________..___________ ▐▌
█ ▐▌
█ VIM 256 COLOR TEST: ▐▌
█ `````````````````` ▐▌
█ Start vim: vim ▐▌
█ Enter: :runtime syntax/colortest.vim ▐▌
█ If your 'red' and 'lightred' look the same, thanks to this article, inform ▐▌
█ Vim that your terminal supports 256 colors: ▐▌
█ :let &t_Co=256 ▐▌
█ Run the test again: ▐▌
█ :runtime syntax/colortest.vim ▐▌
█ To quit vim: :quit ▐▌
█ echo $TERM ▐▌
█ If the reply is xterm then do this: ▐▌
█ export TERM=xterm-256color ▐▌
█ Check if you have ncurses-term installed and install if you don't: ▐▌
█ aptitude search ncurses-term ▐▌
█ Run test again: vim "+runtime syntax/colortest.vim" ▐▌
█ :let &t_Co=256 ▐▌
█ ▐▌
█ My results; First image on left is after just opening the colortest (in ▐▌
█ each image is a comparison; SecureCRT on left and PuTTY on ▐▌
█ right). Second image on right is after doing all the above steps: ▐▌
█ BEFORE: AFTER: ▐▌
█ ▐▌
█ ___________..___________ ▐▌
█ ▐▌
█ CHANGE EMAC'S COLOR THEME: ▐▌
█ `````````````````````````` ▐▌
█ To change Emacs' colors for: ▐▌
█ Debian - you need the add-on color-theme included in emacs-goodies-el : ▐▌
█ Miscellaneous add-ons for Emacs ▐▌
█ ▐▌
█ ▐▌
█ For Gentoo and Slackware color-theme ▐▌
█ ▐▌
█ su ▐▌
█ Debian: ▐▌
█ aptitude install emacs-goodies-el ▐▌
█ Gentoo: ▐▌
█ emerge color-theme ▐▌
█ Slackware via SBo: ▐▌
█ sbopkg -i color-theme-el ▐▌
█ y ▐▌
█ exit ▐▌
█ To view location and what was included: ▐▌
█ ls -al /usr/share/emacs23/site-lisp/emacs-goodies-el ▐▌
█ ▐▌
█ To change your color theme: ▐▌
█ emacs ▐▌
█ M-x color-theme-select RET ▐▌
█ (That is Esc + x color-theme-select then press Enter key) ▐▌
█ ▐▌
█ Use your arrow keys to navigate, press Enter to select/preview it, repeat ▐▌
█ to select another. ▐▌
█ Press d to view a description of the theme, d again to exit description ▐▌
█ mode. ▐▌
█ Top of menu select reset or quit, or press q. ▐▌
█ ▐▌
█ The theme will only be for that session. To make it permanent: ▐▌
█ cd ~ ▐▌
█ pico .emacs ▐▌
█ Add these lines at the end of the file (if that file doesn't exist doing ▐▌
█ this will create it) changing the color-theme name 'renegade' to your ▐▌
█ selected theme: ▐▌
;; Set color-theme
(require 'color-theme)
(color-theme-initialize)
(color-theme-renegade)
█ ▐▌
█ To disable the color-theme for that session: ▐▌
█ M-x disable-theme ▐▌
█ ▐▌
█ Note: If you have set a special color or font for the minibuffer, the ▐▌
█ color-theme will not override it, the command part of it i.e. 'M-x'. ▐▌
█ ▐▌
█ To change the color and or font of emac's minibuffer view HERE. ▐▌
█ ▐▌
█ If you installed the emacs-goodies-el I just want to mention a few of the ▐▌
█ fun ones: ▐▌
█ zcat /usr/share/doc/emacs-goodies-el/README.Debian.gz ▐▌
█ or ▐▌
█ zmore /usr/share/doc/emacs-goodies-el/README.Debian.gz ▐▌
█ ▐▌
█ M-x bar-cursor-mode - change your cursor to a bar instead of a block ▐▌
█ ▐▌
█ M-x boxquote Enter key, then tab key to bring up its menu. ▐▌
█ ,----[ nice title ] ▐▌
█ | boxquote.el allows the easy creation of boxes that look like this, ▐▌
█ | with a nice title and all. Look for the M-x boxquote-* commands. ▐▌
█ `---- ▐▌
█ ▐▌
█ M-x obfuscate-url - obfuscate a path under the cursor in a URL ▐▌
█ ▐▌
█ M-x sm-add-random-header silly-mail generates random silly mail headers to ▐▌
█ put in your outgoing messages required though is shop.el and flame.el ▐▌
█ ▐▌
█ M-x thinks provides cartoon-like think bubbles . o O ( like this ) ▐▌
█ ▐▌
█ ___________..___________ ▐▌
█ ▐▌
█ LOLCAT - OUTPUT COLORIZED TEXT: ▐▌
█ ``````````````````````````````` ▐▌
█ lolcat can do what 'cat' does but colorized and more. "Okay, no unicorns. ▐▌
█ But rainbows!!" That's okay, I still lubs LOLcat :) While you could output ▐▌
█ cat in a singular color using tput, for example light green: ▐▌
█ tput setaf 2;cat myfile;tput sgr0 ▐▌
█ colorized looks great. ▐▌
█ ▐▌
█ ▐▌
█ PREREQUISITES: ▐▌
█ ruby libgemplugin-ruby gem, (the others required will be installed when ▐▌
█ installing lolcat) ▐▌
█ Install what you don't have, for example: ▐▌
█ su ▐▌
█ apt-get install ruby gem libgemplugin-ruby -y ▐▌
█ After that is complete: ▐▌
█ gem install lolcat ▐▌
█ Reply will be similar to: ▐▌
█ +-- info ---------------------------+ ▐▌
█ J-_-L | https://github.com/janlelis/paint | ▐▌
█ +-- usage --------------------------| ▐▌
█ | require 'paint' | ▐▌
█ \ | puts Paint['J-_-L', :red] # J-_-L | ▐▌
█ +-----------------------------------+ ▐▌
█ Successfully installed paint-0.8.6 ▐▌
█ Successfully installed trollop-1.16.2 ▐▌
█ Successfully installed lolcat-42.0.99 ▐▌
█ 3 gems installed ▐▌
█ [snip] ▐▌
█ ▐▌
█ exit ▐▌
█ ▐▌
█ lolcat --help ▐▌
█ -bash: lolcat: command not found ▐▌
█ ▐▌
█ TROUBLE SHOOTING - Skip if your 'lolcat -h' works: ▐▌
█ -bash: lolcat: command not found ▐▌
█ Installing lolcat on my Debian didn't set the paths for lolcat. ▐▌
█ gem which lolcat ▐▌
█ No output. ▐▌
█ ▐▌
█ To list 'gems' installed: ▐▌
█ gem list --local ▐▌
█ My output: ▐▌
█ *** LOCAL GEMS *** ▐▌
█ lolcat (42.0.99) ▐▌
█ paint (0.8.6) ▐▌
█ trollop (1.16.2) ▐▌
█ ▐▌
█ gem contents lolcat ▐▌
█ Or use find: ▐▌
█ cd / && find . -name lolcat* -print ▐▌
█ My output: ▐▌
█ [snip] ▐▌
█ /var/lib/gems/1.8/gems/lolcat-42.0.99/bin/lolcat ▐▌
█ [snip] ▐▌
█ ▐▌
█ So there it is, test if working: ▐▌
█ /var/lib/gems/1.8/bin/lolcat --help ▐▌
█ (Note --help: github.org should be .com) ▐▌
█ It needs to be added to the environment's PATH. ▐▌
█ To do that for yourself and this session only (change path to the location ▐▌
█ of your lolcat): ▐▌
█ export PATH="$PATH:/var/lib/gems/1.8/bin" ▐▌
█ ▐▌
█ To have that permanent for you only: ▐▌
█ pico .bashrc ▐▌
█ Add this line at the bottom of the file with the other paths: ▐▌
█ export PATH="/var/lib/gems/1.8/bin:$PATH"; ▐▌
█ ▐▌
█ Or to have lolcat available system wide: ▐▌
█ su ▐▌
█ pico /etc/profile ▐▌
█ Add this to the end of PATH list and save changes: ▐▌
█ :/var/lib/gems/1.8/bin ▐▌
█ For example mine has this: ▐▌
█ PATH="/usr/local/bin:/usr/bin:/bin:/usr/games" ▐▌
█ I changed it to: ▐▌
█ PATH="/usr/local/bin:/usr/bin:/bin:/usr/games:/var/lib/gems/1.8/bin" ▐▌
█ ▐▌
█ exit ▐▌
█ lolcat --help ▐▌
█ (btw 'lolcat --halp' is gone :< ) ▐▌
█ ▐▌
█ LOLCAT EXAMPLES: ▐▌
█ ▐▌
█ ▐▌
█ lolcat myfile ▐▌
█ cat -n myfile | lolcat (-n is cat's option to number the lines) ▐▌
█ ls | lolcat ▐▌
█ Animate it: ▐▌
█ ls | lolcat -a ▐▌
█ ASCII art rolling show: ▐▌
█ curl -s http://mewbies.com/asciiart/{01..04}.txt | lolcat -a -d 1 -F 0.09 ▐▌
█ (Note curl usage: To specify a variety of file names instead: {x,y,z}.txt)▐▌
█ Video of the above command line playing: ▐▌
█ ▐▌
█ ▐▌
█ Music credits (a snippet embeded after): By 020200, for 2063music, album ▐▌
█ '020222 - opac base ep', track OPAC3base, year 2001. ▐▌
█ ▐▌
█ If you love cowsay: ▐▌
█ curl -s http://mewbies.com/asciiart/guide_to_cows.txt | lolcat -a -d 1 -s 4 -F 0.09
█ Endless output: ▐▌
█ yes mewbies | tr '\n' ' ' | fold -w $COLUMNS | lolcat ▐▌
█ To quit: Ctrl+c ▐▌
█ cat /dev/urandom | base64 -w $COLUMNS | lolcat ▐▌
█ To quit: Ctrl+c ▐▌
█ Check it is indeed stopped: ps x | lolcat ▐▌
█ ▐▌
█ Create an alias for the common commands you want to use with lolcat: ▐▌
█ For example: ▐▌
█ alias lolx="ps x | lolcat" ▐▌
█ Test it: lolx ▐▌
█ To remove it: unalias lolx ▐▌
█ To list all aliases: alias ▐▌
█ alias lolfly="ps -efly | lolcat" ▐▌
█ alias loltree="pstree -acpu | lolcat" ▐▌
█ ▐▌
█ ___________..___________ ▐▌
█ ▐▌
█ SUPERCAT - SYNTAX COLORIZING: ▐▌
█ ````````````````````````````` ▐▌
█ Supercat colorizes text based on matching regular expressions/strings/ ▐▌
█ characters. Supercat supports html output as well as standard ASCII text. ▐▌
█ Unlike some text-colorizing programs that exist, Supercat does not require ▐▌
█ you to have to be a programmer to make colorization rules. Debian package ▐▌
█ info. ▐▌
█ ▐▌
█ su ▐▌
█ aptitude install supercat ▐▌
█ exit ▐▌
█ cat /usr/share/doc/supercat/README.Debian (ack, blue default, so hard to ▐▌
█ see, I'll change that after). ▐▌
█ man spc (online here) ▐▌
█ spc uses a configuration file for each language type so that it knows how ▐▌
█ to create the syntax highlighting. All config files are spcrc-ext; 'ext' ▐▌
█ is the file type: ▐▌
█ ls -al /etc/supercat/ ▐▌
█ spcrc-access_log spcrc-emerge spcrc-py ▐▌
█ spcrc-c spcrc-error_log spcrc-svn ▐▌
█ spcrc-ChangeLog spcrc-gentooconfd spcrc-xorg ▐▌
█ spcrc-diff spcrc-patch ▐▌
█ ▐▌
█ EXAMPLES: ▐▌
█ We'll use one of Supercat's source file so that we have the same example: ▐▌
█ wget http://mewbies.com/geek_fun_files/supercat/spc.c ▐▌
█ spc spc.c ▐▌
█ And to output the results to HTML: ▐▌
█ spc spc.c -w >supercat_output_c_file_to_html.htm ▐▌
█ HERE are the results. ▐▌
█ ▐▌
█ You can state the type a file is, for example below file I know is python: ▐▌
█ spc -t py slowcat ▐▌
█ To show debug to view where it first searches (your home) and state which ▐▌
█ config file: ▐▌
█ spc -t py -d -C/etc/supercat slowcat ▐▌
█ ▐▌
█ EDIT SUPERCAT COLOR OUTPUT: ▐▌
█ You could easily create your own and or copy to your home directory the ▐▌
█ config files for spc to read off. To change the output color, I'll use the ▐▌
█ .py config file 'spcrc-py' and place in my home .spcrc directory: ▐▌
█ mkdir .spcrc ▐▌
█ cp /etc/supercat/spcrc-py ~/.spcrc ▐▌
█ Since I don't like the blue output part, I'll change it to 'b'right cyan: ▐▌
█ pico ~/.spcrc/spcrc-py ▐▌
█ Change this line: ▐▌
█ Blue blu b r (#.*) ▐▌
█ To: ▐▌
█ Cyan cya b r (#.*) ▐▌
█ ▐▌
█ Save your changes and test again. Move cursor over the image below to view ▐▌
█ the changes, click on image for the HTML output: ▐▌
█ ▐▌
█ ▐▌
█ ___________..___________ ▐▌
█ ▐▌
█ MORE MORE MORE: ▐▌
█ ``````````````` ▐▌
█ 'colorgcc' Colorize compiler gcc output, on github also. ▐▌
█ ▐▌
█ 'ANSIColors' "A Python script and module to simply 'use' ANSI Colors in a ▐▌
█ terminal. Python 2.7.1 or higher is required." ▐▌
█ ▐▌
█ 'ANSI colors for Python' "A simple module to add ANSI colors and ▐▌
█ decorations to your strings". ▐▌
█ ▐▌
█ //---------------------------------------------------------------------- ▐▌
█ ▐▌
█ If you find mistakes, have suggestions, and or questions please post at ▐▌
█ mewbies forum HERE - thank you. ▐▌
█ ▐▌
█ Last update on 07 Jun '13 ▐▌
█ ▐▌
█▌ █▌
█▌ - mewbies.com - █▌
█▌ █▌
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██