📅 November 30, 2017
👷 Chris Power
I’ve always been a bit of a chameleon when it comes to colors in my terminal. I am never settled on just one scheme. Sometimes I’ll go a couple weeks on a dark scheme like railscasts, just to switch over to solarized-light.
The switching back and forth was pretty frustrating. Each time I switch, I have to update my ~/.zshrc file to load a new colorscheme. THEN I’d update my ~/.vimrc to match. I’d also have to restart my current vim sessions so the editor runs with the new scheme.
###This was all pretty annoying until I discovered:
I have both these packages set up on my machine, it allows me to do this:
I use vim-plug to handle my vim dependencies and strongly suggest anyone else use the same. Put this in your ~/.vimrc file:
Plug 'chriskempson/base16-vim' and run something like
vim +PlugInstall +qa and you should be up and running! This will install all the base16 colorschemes for use in vim.
Install base16-shell with the auto-completion. This is all lifted from the repo’s README linked above:
git clone https://github.com/chriskempson/base16-shell.git ~/.config/base16-shell
Next (for autocompletion) place these lines in your ~/.zshrc or ~/.bashrc:
BASE16_SHELL=$HOME/.config/base16-shell/ [ -n "$PS1" ] && [ -s $BASE16_SHELL/profile_helper.sh ] && eval "$($BASE16_SHELL/profile_helper.sh)"
Finally, you’ll need to update your ~/.vimrc to include a file that gets created/updated from base16-shell. Again, lifted from the great README in the repo:
if filereadable(expand("~/.vimrc_background")) let base16colorspace=256 source ~/.vimrc_background endif
And there you have it! Base16-shell will set up your colors, and modify a vimrc file to upadte your colorscheme. As long as you’re sourcing this file in your ~/.vimrc, you’ll be able to automatically see the updates to your colorscheme in all running vim instances!