Base16 color schemes¶
Introduction¶
I spend a lot of my computer time in front of a Debian GNU/Linux box in a tmux session with multiple windows and panes (opened in an xterm), editing text files with Vim or just doing command line work in Bash.
I’m using the Base16 theming system and appreciate that it makes it possible to
keep tmux and all my panes (with or without Vim opened in them) synchronized
with regard to the colors. I just have to issue a single command (like
base16_classic-dark
) in one of the panes to switch the color scheme
everywhere.
Cloning Base16 repositories locally¶
Just issue some git clone
commands (as a normal user) in specific
subdirectories of your home directory:
cd ~/.config
git clone https://github.com/tinted-theming/base16-shell.git
cd ~/.vim
git clone https://github.com/tinted-theming/base16-vim.git
cd ~/.tmux/plugins
git clone https://github.com/tinted-theming/base16-tmux.git
Configuration¶
Enable 256 colors in terminals¶
Make sure you have the following line in your ~/.Xresources
:
Have the color scheme applied on Bash startup¶
You need to tweak your ~/.bashrc
file to have the color scheme applied on
Bash startup. I didn’t exactly follow the recommendations in the README of
base16-shell. Instead I
added the following snippet to my ~/.bashrc
:
It makes sure that the color scheme is applied only when you’re in a terminal or in a tmux session, not when you’re in a login shell in a text console.
The BASE16_SHELL_SET_BACKGROUND=false
causes the background color of the
color scheme to be ignored. Without that, I find that most of the dark schemes
have a background color that is not black enough. The downside is that the
light schemes are pretty much unusable, but I wouldn’t use them anyway…
Have the color scheme applied in Vim¶
First I created the ~/.vim/colors
symbolic link with
~/.vim/base16-vim/colors
as the target:
cd ~/.vim
ln -s base16-vim/colors
Then I added the following snippet to my ~/.vimrc
:
This is what is recommended in the README of base16-shell, except for the
base16_background_transparent=1
part that I had to add for the same reason
as I added BASE16_SHELL_SET_BACKGROUND=false
above. The
!has("gui_running")
condition ensures the the transparent background option
is applied only in “terminal” Vim and not in graphical Vim (gvim). In gvim, the
transparent background option leads to a white background.
Have the color scheme applied in tmux¶
The Base16 theming system seems to work well with the following lines at the
top of the ~/.tmux/conf
file:
Choosing a color scheme¶
There are more than 260 Base16 color schemes, so you’re spoilt for choice!
You can see the list of the base16 schemes with this command:
alias | grep "^alias base16_"|sed "s/=.\+$//"|sed "s/^.\+ //"
The Base16 Gallery helps to make a choice.
Alternatively, you can cycle through all the schemes with the following commands (3 seconds delay before switching to the next scheme):
ALL_SCHEMES=$(alias|grep "^alias base16_"|sed 's/^[^"]\+"\([^"]\+\)".*$/\1/')
for S in $ALL_SCHEMES; do sleep 3; echo "$S"; set_theme "$S"; done
If you want to exclude the schemes with “-light” in their name, do:
ALL_SCHEMES=$(alias|grep "^alias base16_"|sed 's/^[^"]\+"\([^"]\+\)".*$/\1/')
ALL_NON_LIGHT_SCHEMES=$(echo $ALL_SCHEMES | tr " " "\n" | grep -v "\-light")
for S in $ALL_NON_LIGHT_SCHEMES; do sleep 3; echo "$S"; set_theme "$S"; done
Finally, to cycle through my favorite dark schemes, use:
for S in \
3024 \
atelier-plateau \
atlas \
brewer \
circus \
codeschool \
darcula \
darktooth \
embers \
everforest \
grayscale-dark \
irblack \
kanagawa \
ocean \
papercolor-dark \
paraiso \
phd \
pico \
primer-dark-dimmed \
sandcastle \
solarflare \
standardized-dark \
summercamp \
twilight \
vulcan \
; do sleep 3; echo "$S"; set_theme "$S"; done