Skip to content
This repository has been archived by the owner on Jul 6, 2022. It is now read-only.

tinted-theming/base16-shell-legacy

Repository files navigation

Base16 Shell

See the Base16 repository for more information.

A shell script to change your shell's default ANSI colors but most importantly, colors 17 to 21 of your shell's 256 colorspace (if supported by your terminal). This script makes it possible to honor the original bright colors of your shell (e.g. bright green is still green and so on) while providing additional base16 colors to applications such as Vim and tmux.

Base16 Shell

Use Cases

  • You want to use a *.256.* variant of a Terminal theme designed to honor the original bright colors.
  • You prefer to use a script instead of a terminal emulator theme to color your shell.
  • You use this script to have different colorschemes appear on different SSH sessions.

Installation

git clone https://github.com/base16-project/base16-shell.git \
  $HOME/.config/base16-shell

Bash/ZSH

Add following lines to .bashrc or .zshrc:

# Base16 Shell
BASE16_SHELL_PATH="$HOME/.config/base16-shell"
[ -n "$PS1" ] && \
  [ -s "$BASE16_SHELL_PATH/profile_helper.sh" ] && \
    source "$BASE16_SHELL_PATH/profile_helper.sh"

Oh my zsh

mkdir $HOME/.oh-my-zsh/plugins/base16-shell
ln -s $HOME/.config/base16-shell/base16-shell.plugin.zsh \
  $HOME/.oh-my-zsh/plugins/base16-shell/base16-shell.plugin.zsh

To use it, add base16-shell to the plugins array in your .zshrc file:

plugins=(... base16-shell)

Fish

Add following lines to $HOME/.config/fish/config.fish:

# Base16 Shell
if status --is-interactive
  set BASE16_SHELL_PATH "$HOME/.config/base16-shell"
  source "$BASE16_SHELL_PATH/profile_helper.fish"
end

Configuration

Base16-Vim Users

Vim

The BASE16_THEME environment variable will set to your current colorscheme. You can set the base16-vim colorscheme to the BASE16_THEME environment variable by adding the following to your .vimrc:

if exists('$BASE16_THEME')
    \ && (!exists('g:colors_name') 
    \ || g:colors_name != 'base16-$BASE16_THEME')
  let base16colorspace=256
  colorscheme base16-$BASE16_THEME
endif

Remove the base16colorspace line if it is not needed.

Neovim

If you have a lua neovim config, add the following to your init.lua:

local cmd = vim.cmd
local g = vim.g

local base16_project_theme = os.getenv('BASE16_THEME')
if base16_project_theme and g.colors_name ~= 'base16-'..base16_project_theme then
  cmd('let base16colorspace=256')
  cmd('colorscheme base16-'..base16_project_theme)
end

Base16-Tmux Users

This section is for base16-tmux users. base16-shell will update (or create) the $HOME/.config/base16-project/tmux.base16.conf file and set the colorscheme. You need to source this file in your .tmux.conf. You can do this by adding the following to your .tmux.conf:

source-file $HOME/.config/base16-project/tmux.base16.conf

Make sure to reload your .tmux.conf file after the theme has been updated through profile_helper.

Keeping your themes up to date

To update, just git pull wherever you've cloned base16-shell. The themes are updated on a weekly basis thanks to GitHub Actions. See the GitHub Actions workflow in .github/workflows/update.yml.

Default theme

You can set the $BASE16_THEME_DEFAULT environment variable to the name of a theme and it will use that theme if there is no theme currently set. This can be useful for when you're using your dotfiles in a brand new environment and you don't want to manually set the theme for the first time.

For example: $BASE16_THEME_DEFAULT="solarized-light"

Usage

Open a new shell and type base16 followed by a tab to perform tab completion.

Troubleshooting

Run the included colortest script and check that your colour assignments appear correct. If your teminal does not support the setting of colours in within the 256 colorspace (e.g. Apple Terminal), colours 17 to 21 will appear blue.

setting 256 colourspace not supported

If colortest is run without any arguments e.g. ./colortest the hex values shown will correspond to the default scheme. If you'd like to see the hex values for a particular scheme pass the file name of the theme as the arguement e.g. ./colortest base16-ocean.sh.

Inverted blacks and whites

This is the expected behaviour when using a light theme: https://github.com/base16-project/base16-shell/issues/150

Contributing

See CONTRIBUTING.md, which contains building and contributing instructions.