Colors scripts

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

colors

  • Create a folder ~/bin/
  • Create a file ‘termcolors’ as follow:
#!/bin/bash 
\#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 :
PATH=$PATH:/home/user/bin/
export PATH
  • Add the new variable to the environment :
$ source ~/.bashrc

Just run script name to execute it :

$ termcolors

Links:

Advertisements

Comments are closed.

Create a free website or blog at WordPress.com.

Up ↑