Colors scripts

How to create a simple bash script to display your terminal colors saved in .Xdefaults (or .Xressources).


  • Create a folder ~/bin/
  • Create a file ‘termcolors’ as follow:
\#setterm -regtabs 
COLS="$(xrdb -query| grep -Ei [.*]color[01-9] | sort -n -tr -k2 | tr -d [*[:blank:]])"
echo -en "---------------------------------------------------------------"; 
echo -e "33[0m" 
for i in {0..7}; do echo -en "\e[0;3${i}m▉▉▉▉▉▉▉\t"; done; echo 
for i in {0..7}; do echo -en "\e[0;9${i}m▉▉▉▉▉▉▉\t"; done; echo -e "33[0m" 
echo -en "---------------------------------------------------------------";
echo -e "33[0m"
  • Make it executable : $ chmod 755 termcolors
  • Add ~/bin/ to your PATH with this line at the end of ~/.bashrc :
export PATH
  • Add the new variable to the environment :
$ source ~/.bashrc

Just run script name to execute it :

$ termcolors



Comments are closed.

Blog at

Up ↑