Dat Pretty Vim: 256 colours in Bash

Colourful Vim Screen

After many years of being used to bland, black-and-white SSH sessions and plain vanilla Vi for my troubleshooting works – I’ve finally decided to take some time to learn how to juice the shells up a bit with glorious 256 colours and Vim’s syntax-on and color option. It was surprising how Vim suddenly became a pleasure to work with.

The following applies to CentOS/RHEL 6 on Bash shell; but it should probably work with many other similar flavours of Linux.

Create a script as below with a name of your choice (I named it xterm256.sh) under /etc/profile.d directory.

if [ "$TERM" == "xterm" ]; then
    export TERM=xterm-256color
fi

Save the script, and log out and back in again to shell. Running

echo $TERM

will now show

xterm-256color

Since it runs under /etc/profile.d directory, any user SSH’ing into the server will now run in 256 colour mode.

Now, go search for some Vim color themes and you are all set.

One thought on “Dat Pretty Vim: 256 colours in Bash

Leave a Reply

Your email address will not be published.