Create a themes/
folder under ~/.config/alacritty
.
~/.config/alacritty
❯ ls -h
alacritty.yml theme.yml themes
Create a theme.yml
file under ~/.config/alacritty
and import it in your own Alacritty config, at the very end of it:
# ~/.config/alacritty/alacritty.yml
# (...)
import:
- ~/.config/alacritty/theme.yml
Themes are just plain Alacritty configuration files with color overrides and their file names are their keys. Here's Solarized Dark, for example:
# ~/.config/alacritty/themes/solarized-dark.yml
colors:
primary:
background: '0x002b36'
foreground: '0x839496'
normal:
black: '0x073642'
red: '0xdc322f'
green: '0x859900'
yellow: '0xb58900'
blue: '0x268bd2'
magenta: '0xd33682'
cyan: '0x2aa198'
white: '0xeee8d5'
bright:
black: '0x002b36'
red: '0xcb4b16'
green: '0x586e75'
yellow: '0x657b83'
blue: '0x839496'
magenta: '0x6c71c4'
cyan: '0x93a1a1'
white: '0xfdf6e3'
Enable live_config_reload
on your Alacritty settings. This is so you don't have to manually reload/restart Alacritty for config changes to take effect.
Lastly add an alacritty-theme
function to your zsh/bash profile:
function alacritty-theme() {
local new_theme="${1:-dracula-pro}" # defaults to `dracula-pro` :heart:
local config_path="$HOME/.config/alacritty"
local themes_path=$config_path/themes
local new_theme_file="$themes_path/$new_theme.yml"
if [ ! -f $new_theme_file ]; then
echo "Invalid Alacritty theme: $new_theme"
return
fi
echo "import:\n - $new_theme_file" > $config_path/theme.yml
}