Enable 256 Color Terminal in Ubuntu
Enable 256 Color Terminal in Ubuntu – Sometimes when you try to set the colorscheme of your terminal based editors such as vim or tumx, colors looked pretty strange. It was not as promised in theme screenshot!
When you try to set the colorscheme of your terminal based editors, colors looked pretty strange. Because our terminal supported 8 bit colors only while we were trying to set 256 colors in the terminal.
It was happening because our terminal supported 8 bit colors only while we were trying to set 256 colors in the terminal.
So first we have to get some information about our terminal – We would run following commands to check the details about the color depth of terminal, type of terminal etc.
Type these commands and check your results:
This will report how many colors your terminal is using.
This will tell you what terminal you are using.
If you are using a gnome you should see “gnome-terminal”
If you get the result of tput colors as 256 then voila! your system already has 256 color terminal otherwise if you get something less than 256 then you need some work to Enable 256 Color Terminal.
The gnome-terminal in latest versions of Ubuntu already supports 256 colors, however it still reports its term type as “xterm” indicating it supports only 8 colors. Since $TERM is set to “xterm” which is just 8 bit terminal and applications such as “tmux”,“vim” decides the number of supported colors based on environment variable “TERM”.
Lot of people suggest using below code in you .bashrc file in order to Enable 256 Color Terminal but in my opinion this should be avoided because environment variable “TERM” should be reported by the terminal instead of the shell. It can raise confilict when other applications such as putty try to use it.
if [ "$COLORTERM" == "gnome-terminal" ] || [ "$COLORTERM" == "xfce4-terminal" ] then TERM=xterm-256color elif [ "$COLORTERM" == "rxvt-xpm" ] then TERM=rxvt-256color fi
You can follow another but simple approach to Enable 256 Color Terminal in Ubuntu as shown in screenshot –
Replace with version of your shell e.g Zsh or Bash
Now after making the changes lets run those command again to see the changes
Awesome! Now we enabled 256 colors in Ubuntu terminal as we can see in the screenshot.
Another Approach ( Only if you are using Oh My Zsh)-
256color ZSH Plugin is a plugin for Oh My Zsh. If you use Oh-My-Zsh, add zsh-256color to your plugins list and clone this repository to your $ZSH_CUSTOM/plugins directory:
$ ( cd $ZSH_CUSTOM/plugins && git clone https://github.com/chrissicool/zsh-256color )
As per their description is given on github –
If you do not want to use this plugin and manually install using ncurses.
sudo apt-get install ncurses-term
So these are the ways to Enable 256 Color Terminal in Ubuntu and another approaches or suggestions to do the same are welcome.
- READ MORE: How to install WordPress in Linux Mint?