Color me baby! — 2017 Mar 21
It's been a while since my last post. I had been a bit troubled by the pace of things happening in life. Anyways I'm back and well ... Happy new year!
Now that we've got that out of the way, let's start colorising our $TERMINAL. This write up is a list of things, that make me happy at the command-line. It basically covers programs, with a lil' bit of shell-fu, that spit way more colors than they should. But hey, it's uber cool than just a green terminal.
Inorder to have "full color", our terminal emulator should support it. I use xfce4-terminal as my terminal. And in my $SHELL's rc file (usually the most common $HOME/.bashrcor $HOME/.zshrc), I would add a line that goes export TERM="xterm-256color". I also from time to time use tmux which is a terminal multiplexer. The following snippet should be added to the top of $HOME/.tmux.conf for a seamless colorful terminal experience.
## yeah! moar color support set -g default-terminal "screen-256color" # doesn't hurt if utf support is enabled :) set -g utf8 set-window-option -g utf8 on
Let's do this
Colors to shell scripts
In my $SHELL's rc file, I'd assign a set of colors to a set of variables. And then use those variables whenever I want to display certain text in color. This is a snippet from my $HOME/.bashrc file.
Now I can use these variables in my $SHELL session or scripts as per the screenshot below
# text normal colors red='\e[0;31m' blue='\e[0;34m' cyan='\e[0;36m' green='\e[0;32m' yellow='\e[0;33m' # text bright colors bred='\e[0;91m' bblue='\e[0;94m' bcyan='\e[0;96m' bgreen='\e[0;92m' byellow='\e[0;93m' bwhite='\e[0;97m' # reset color NC='\e[0m'
shell colors to highlight important stuff
While we're at it, we might want to colorize our prompt too. My prompt is a simple %. In debian based systems, uncomment force_color_prompt=yes in $HOME/.bashrc for the default colored prompt.
The default ls command that we're all familiar with, has a --color=auto option that gives pretty sweet colors while listing files and directories. But I want something more like this ...
ls on steroids
Head over to the project's git page and install it. I usually put a alias ls="ls++" in my $SHELL's rc file. Do note that the program uses a config file, as mentioned in the project's github page. We can also specify custom colors for each file-type using dircolors. Put a custom .dircolors file in our $HOME. Then add a few lines in $HOME/.bashrc that reads
This is the dircolors file that I use.
# color specifics for ls if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" fi
Zsh syntax highlighting
If you're not into switching shells, you may skip this. But do give zsh a try as its a beautiful piece of software. I am ashamed to admit it, but this was the first thing that made me try zsh. Get the project from here. Put it in a safe place and add the following to our $HOME/.zshrc
# syntax highlighting source ~/.config/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh #adjust accordingly ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets) ZSH_HIGHLIGHT_STYLES[default]='none' ZSH_HIGHLIGHT_STYLES[unknown-token]='fg=red' ZSH_HIGHLIGHT_STYLES[reserved-word]='fg=yellow' ZSH_HIGHLIGHT_STYLES[alias]='fg=blue' ZSH_HIGHLIGHT_STYLES[builtin]='fg=blue' ZSH_HIGHLIGHT_STYLES[function]='fg=blue' ZSH_HIGHLIGHT_STYLES[command]='fg=blue' ZSH_HIGHLIGHT_STYLES[precommand]='none' ZSH_HIGHLIGHT_STYLES[commandseparator]='none' ZSH_HIGHLIGHT_STYLES[hashed-command]='fg=blue' ZSH_HIGHLIGHT_STYLES[path]='none' ZSH_HIGHLIGHT_STYLES[path_prefix]='none' ZSH_HIGHLIGHT_STYLES[path_approx]='fg=yellow' ZSH_HIGHLIGHT_STYLES[globbing]='fg=green' ZSH_HIGHLIGHT_STYLES[history-expansion]='fg=green' ZSH_HIGHLIGHT_STYLES[single-hyphen-option]='fg=magenta' ZSH_HIGHLIGHT_STYLES[double-hyphen-option]='fg=red' ZSH_HIGHLIGHT_STYLES[back-quoted-argument]='none' ZSH_HIGHLIGHT_STYLES[single-quoted-argument]='fg=yellow' ZSH_HIGHLIGHT_STYLES[double-quoted-argument]='fg=yellow' ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]='fg=cyan' ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]='fg=cyan' ZSH_HIGHLIGHT_STYLES[assign]='none'
Lolcat is our friend cat with rainbow puking powers. A sudo apt install lolcat and we'll end up with something like ...
i haz rainbows
The man page has a bit more info on what we can do with lolcat. Do read up and enjoy happiness.
This is also a colorizer program like lolcat. Install it with sudo apt install grc and then ...
ping looks beautiful
Consult the man pages for more examples.
Our good old filesystem viewer df plus graphs, bars, colors = dfc. Git it and enjoy.
Ahem!! read the man page?
I know this is only a few things, but I hope you go out and rice your masterpiece. Eye candy is an important part of everything I do. It makes having to look at a screen, a pleasure.
I hope the "one-more-thing-to-rice" bug has bitten you. And oh! if you're into this, drop by at the BBQ.
Have a great day!