Automate switching between day/night color schemes
This sets up individual light and dark color scheme files for vim/neovim and alacritty, adds a script (`set-color`) for placing them, and includes two no-arg scripts for later keybinding (`day-mode` and `night-mode`). Thanks to this blog post for the idea to `cat` the YAML into place: https://shuheikagawa.com/blog/2020/02/14/switching-colorschemes-of-vim-and-alacritty/ TIL YAML is concatenative!
This commit is contained in:
parent
48ba022ae7
commit
be5708c8c7
14 changed files with 165 additions and 60 deletions
5
alacritty/.gitignore
vendored
Normal file
5
alacritty/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Generated by `./install`
|
||||||
|
/alacritty.yml
|
||||||
|
|
||||||
|
# Symlink created by `../bin/set-colors`
|
||||||
|
/colors.yml
|
||||||
|
|
@ -90,51 +90,6 @@ render_timer: false
|
||||||
# and cursor.background colors, otherwise invert the colors of the cursor.
|
# and cursor.background colors, otherwise invert the colors of the cursor.
|
||||||
custom_cursor_colors: false
|
custom_cursor_colors: false
|
||||||
|
|
||||||
# Colors (Tomorrow Night Bright)
|
|
||||||
colors:
|
|
||||||
# Default colors
|
|
||||||
primary:
|
|
||||||
background: '0x000000'
|
|
||||||
foreground: '0xeaeaea'
|
|
||||||
|
|
||||||
# Colors the cursor will use if `custom_cursor_colors` is true
|
|
||||||
cursor:
|
|
||||||
text: '0x000000'
|
|
||||||
cursor: '0xffffff'
|
|
||||||
|
|
||||||
# Normal colors
|
|
||||||
normal:
|
|
||||||
black: '0x000000'
|
|
||||||
red: '0xd54e53'
|
|
||||||
green: '0xb9ca4a'
|
|
||||||
yellow: '0xe6c547'
|
|
||||||
blue: '0x7aa6da'
|
|
||||||
magenta: '0xc397d8'
|
|
||||||
cyan: '0x70c0ba'
|
|
||||||
white: '0xffffff'
|
|
||||||
|
|
||||||
# Bright colors
|
|
||||||
bright:
|
|
||||||
black: '0x666666'
|
|
||||||
red: '0xff3334'
|
|
||||||
green: '0x9ec400'
|
|
||||||
yellow: '0xe7c547'
|
|
||||||
blue: '0x7aa6da'
|
|
||||||
magenta: '0xb77ee0'
|
|
||||||
cyan: '0x54ced6'
|
|
||||||
white: '0xffffff'
|
|
||||||
|
|
||||||
# Dim colors (Optional)
|
|
||||||
dim:
|
|
||||||
black: '0x333333'
|
|
||||||
red: '0xf2777a'
|
|
||||||
green: '0x99cc99'
|
|
||||||
yellow: '0xffcc66'
|
|
||||||
blue: '0x6699cc'
|
|
||||||
magenta: '0xcc99cc'
|
|
||||||
cyan: '0x66cccc'
|
|
||||||
white: '0xdddddd'
|
|
||||||
|
|
||||||
# Visual Bell
|
# Visual Bell
|
||||||
#
|
#
|
||||||
# Any time the BEL code is received, Alacritty "rings" the visual bell. Once
|
# Any time the BEL code is received, Alacritty "rings" the visual bell. Once
|
||||||
27
alacritty/colors-dark.yml
Normal file
27
alacritty/colors-dark.yml
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
colors:
|
||||||
|
# Default colors
|
||||||
|
primary:
|
||||||
|
background: '0x1d1f21'
|
||||||
|
foreground: '0xc5c8c6'
|
||||||
|
|
||||||
|
# Normal colors
|
||||||
|
normal:
|
||||||
|
black: '0x282a2e'
|
||||||
|
red: '0xa54242'
|
||||||
|
green: '0x8c9440'
|
||||||
|
yellow: '0xde935f'
|
||||||
|
blue: '0x5f819d'
|
||||||
|
magenta: '0x85678f'
|
||||||
|
cyan: '0x5e8d87'
|
||||||
|
white: '0x707880'
|
||||||
|
|
||||||
|
# Bright colors
|
||||||
|
bright:
|
||||||
|
black: '0x373b41'
|
||||||
|
red: '0xcc6666'
|
||||||
|
green: '0xb5bd68'
|
||||||
|
yellow: '0xf0c674'
|
||||||
|
blue: '0x81a2be'
|
||||||
|
magenta: '0xb294bb'
|
||||||
|
cyan: '0x8abeb7'
|
||||||
|
white: '0xc5c8c6'
|
||||||
27
alacritty/colors-light.yml
Normal file
27
alacritty/colors-light.yml
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
colors:
|
||||||
|
# Default colors
|
||||||
|
primary:
|
||||||
|
background: '0xf3f3f3'
|
||||||
|
foreground: '0x303030'
|
||||||
|
|
||||||
|
# Normal colors
|
||||||
|
normal:
|
||||||
|
black: '0xdadada'
|
||||||
|
red: '0xf32840'
|
||||||
|
green: '0x059b00'
|
||||||
|
yellow: '0xf06d14'
|
||||||
|
blue: '0x337ada'
|
||||||
|
magenta: '0xac37f5'
|
||||||
|
cyan: '0x0ababe'
|
||||||
|
white: '0x707070'
|
||||||
|
|
||||||
|
# Bright colors
|
||||||
|
bright:
|
||||||
|
black: '0xb3b3b3'
|
||||||
|
red: '0xad1d2f'
|
||||||
|
green: '0x345a09'
|
||||||
|
yellow: '0xb44900'
|
||||||
|
blue: '0x024299'
|
||||||
|
magenta: '0x63039f'
|
||||||
|
cyan: '0x008a86'
|
||||||
|
white: '0x909090'
|
||||||
12
alacritty/install
Executable file
12
alacritty/install
Executable file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
CURDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
inputs=(
|
||||||
|
"${CURDIR}/base.yml"
|
||||||
|
"${CURDIR}/colors.yml"
|
||||||
|
)
|
||||||
|
output="${CURDIR}/alacritty.yml"
|
||||||
|
|
||||||
|
cat "${inputs[@]}" > "${output}"
|
||||||
4
bin/day-mode
Executable file
4
bin/day-mode
Executable file
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
CURDIR="$(cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")" && pwd)"
|
||||||
|
exec "${CURDIR}/set-colors" light
|
||||||
4
bin/night-mode
Executable file
4
bin/night-mode
Executable file
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
CURDIR="$(cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")" && pwd)"
|
||||||
|
exec "${CURDIR}/set-colors" dark
|
||||||
20
bin/set-colors
Executable file
20
bin/set-colors
Executable file
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# "Automate" flipping applications between light and dark themes.
|
||||||
|
|
||||||
|
DOTFILES="$(cd "$(dirname "$(dirname "$(realpath "${BASH_SOURCE[0]}")")")" && pwd)"
|
||||||
|
|
||||||
|
scheme="${1:-dark}"
|
||||||
|
|
||||||
|
if [ "${scheme}" = 'dark' ]; then
|
||||||
|
ln -sf "${DOTFILES}/alacritty/colors-dark.yml" "${DOTFILES}/alacritty/colors.yml"
|
||||||
|
ln -sf "${DOTFILES}/vim/colors/jdkaplan-dark.vim" "${DOTFILES}/vim/colors/jdkaplan.vim"
|
||||||
|
"${DOTFILES}/alacritty/install"
|
||||||
|
elif [ "${scheme}" = 'light' ]; then
|
||||||
|
ln -sf "${DOTFILES}/alacritty/colors-light.yml" "${DOTFILES}/alacritty/colors.yml"
|
||||||
|
ln -sf "${DOTFILES}/vim/colors/jdkaplan-light.vim" "${DOTFILES}/vim/colors/jdkaplan.vim"
|
||||||
|
"${DOTFILES}/alacritty/install"
|
||||||
|
else
|
||||||
|
echo "Unknown color scheme: ${scheme}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
- mkdir -p ~/.config
|
- mkdir -p ~/.config
|
||||||
- mkdir -p ~/.config/direnv
|
- mkdir -p ~/.config/direnv
|
||||||
- mkdir -p ~/.task
|
- mkdir -p ~/.task
|
||||||
|
- ./bin/set-colors dark
|
||||||
|
|
||||||
- clean: ['~', '~/.config']
|
- clean: ['~', '~/.config']
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,6 @@ set number
|
||||||
set hidden
|
set hidden
|
||||||
set ruler
|
set ruler
|
||||||
|
|
||||||
set t_Co=256
|
|
||||||
|
|
||||||
set background=dark
|
|
||||||
colorscheme jdkaplan
|
colorscheme jdkaplan
|
||||||
|
|
||||||
set expandtab
|
set expandtab
|
||||||
|
|
@ -326,3 +323,12 @@ smap <C-k> <Plug>(neosnippet_expand_or_jump)
|
||||||
xmap <C-k> <Plug>(neosnippet_expand_target)
|
xmap <C-k> <Plug>(neosnippet_expand_target)
|
||||||
|
|
||||||
let g:gutentags_ctags_executable_rust = 'rusty-gutentags'
|
let g:gutentags_ctags_executable_rust = 'rusty-gutentags'
|
||||||
|
|
||||||
|
" CTRL-L usually clears and redraws the screen. Might as well use it to reset
|
||||||
|
" the colorscheme too!
|
||||||
|
fun s:ResetScreen()
|
||||||
|
colorscheme jdkaplan
|
||||||
|
redraw
|
||||||
|
endfun
|
||||||
|
command ResetScreen call s:ResetScreen()
|
||||||
|
nnoremap <C-l> :ResetScreen<CR>
|
||||||
|
|
|
||||||
2
vim/colors/.gitignore
vendored
Normal file
2
vim/colors/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Symlink created by `../../bin/set-colors`
|
||||||
|
/jdkaplan.vim
|
||||||
|
|
@ -1,18 +1,17 @@
|
||||||
" Vim color file jdkaplan
|
" Vim color file jdkaplan
|
||||||
|
|
||||||
set background=dark
|
|
||||||
hi clear
|
hi clear
|
||||||
if exists("syntax_on")
|
if exists("syntax_on")
|
||||||
syntax reset
|
syntax reset
|
||||||
endif
|
endif
|
||||||
set t_Co=256
|
set background=dark
|
||||||
let colors_name = "jdkaplan"
|
let colors_name = "jdkaplan"
|
||||||
|
|
||||||
hi Comment cterm=none ctermfg=145
|
hi Comment cterm=none ctermfg=145
|
||||||
hi Constant cterm=none ctermfg=141
|
hi Constant cterm=none ctermfg=141
|
||||||
hi Cursor cterm=none ctermbg=255
|
hi Cursor cterm=none ctermbg=255
|
||||||
hi CursorLine cterm=none ctermbg=0
|
hi CursorLine cterm=none ctermbg=232
|
||||||
hi CursorColumn cterm=none ctermbg=0
|
hi CursorColumn cterm=none ctermbg=232
|
||||||
hi Directory cterm=none ctermfg=33
|
hi Directory cterm=none ctermfg=33
|
||||||
hi ExtraWhitespace cterm=none ctermbg=160
|
hi ExtraWhitespace cterm=none ctermbg=160
|
||||||
hi Folded cterm=none ctermfg=220 ctermbg=59
|
hi Folded cterm=none ctermfg=220 ctermbg=59
|
||||||
|
|
@ -44,5 +43,3 @@ hi Whitespace cterm=none ctermfg=239 ctermbg=235
|
||||||
|
|
||||||
hi ALEWarningSign ctermfg=184 ctermbg=238
|
hi ALEWarningSign ctermfg=184 ctermbg=238
|
||||||
hi ALEErrorSign ctermfg=160 ctermbg=238
|
hi ALEErrorSign ctermfg=160 ctermbg=238
|
||||||
|
|
||||||
hi DeniteMatched NONE cterm=none ctermfg=184 ctermbg=235
|
|
||||||
45
vim/colors/jdkaplan-light.vim
Normal file
45
vim/colors/jdkaplan-light.vim
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
" Vim color file jdkaplan
|
||||||
|
|
||||||
|
hi clear
|
||||||
|
if exists("syntax_on")
|
||||||
|
syntax reset
|
||||||
|
endif
|
||||||
|
set background=light
|
||||||
|
let colors_name = "jdkaplan2"
|
||||||
|
|
||||||
|
hi Comment cterm=none ctermfg=243
|
||||||
|
hi Constant cterm=none ctermfg=63
|
||||||
|
hi Cursor cterm=none ctermbg=232
|
||||||
|
hi CursorLine cterm=none ctermbg=255
|
||||||
|
hi CursorColumn cterm=none ctermbg=255
|
||||||
|
hi Directory cterm=none ctermfg=26
|
||||||
|
hi ExtraWhitespace cterm=none ctermbg=160
|
||||||
|
hi Folded cterm=none ctermfg=220 ctermbg=242
|
||||||
|
hi Function cterm=none ctermfg=32
|
||||||
|
hi Identifier cterm=none ctermfg=32
|
||||||
|
hi LineNr cterm=none ctermfg=244
|
||||||
|
hi MatchParen cterm=none ctermfg=202 ctermbg=254
|
||||||
|
hi Normal cterm=none ctermfg=233 ctermbg=254
|
||||||
|
hi NonText cterm=none ctermfg=110 ctermbg=251
|
||||||
|
hi Number cterm=none ctermfg=202
|
||||||
|
hi PreProc cterm=none ctermfg=28
|
||||||
|
hi SignColumn ctermbg=242
|
||||||
|
hi Statement cterm=none ctermfg=28
|
||||||
|
hi Special cterm=none ctermfg=233
|
||||||
|
hi SpecialKey cterm=none ctermfg=28
|
||||||
|
hi SpellBad NONE cterm=underline " TODO
|
||||||
|
hi SpellCap NONE cterm=underline " TODO
|
||||||
|
hi StatusLine cterm=none ctermfg=232 ctermbg=245
|
||||||
|
hi StatusLineNC cterm=none ctermfg=244 ctermbg=251
|
||||||
|
hi String cterm=none ctermfg=94
|
||||||
|
hi StorageClass cterm=none ctermfg=136
|
||||||
|
hi Title cterm=none ctermfg=233
|
||||||
|
hi Todo cterm=none ctermfg=196 ctermbg=254
|
||||||
|
hi Type cterm=none ctermfg=136
|
||||||
|
hi Underlined cterm=underline ctermfg=233
|
||||||
|
hi VertSplit cterm=none ctermfg=248
|
||||||
|
hi Visual cterm=none ctermfg=233 ctermbg=252
|
||||||
|
hi Whitespace cterm=none ctermfg=244 ctermbg=253
|
||||||
|
|
||||||
|
hi ALEWarningSign ctermfg=184 ctermbg=249
|
||||||
|
hi ALEErrorSign ctermfg=160 ctermbg=249
|
||||||
12
zsh/.zshrc
12
zsh/.zshrc
|
|
@ -32,12 +32,12 @@ zle -N edit-command-line
|
||||||
bindkey '^x^e' edit-command-line
|
bindkey '^x^e' edit-command-line
|
||||||
|
|
||||||
if [[ $TERM =~ '256color' ]]; then
|
if [[ $TERM =~ '256color' ]]; then
|
||||||
local blue="%F{81}"
|
local blue="%F{12}"
|
||||||
local orange="%F{166}"
|
local orange="%F{11}"
|
||||||
local purple="%F{135}"
|
local purple="%F{13}"
|
||||||
local red="%F{196}"
|
local red="%F{9}"
|
||||||
local green="%F{118}"
|
local green="%F{10}"
|
||||||
local gray="%F{241}"
|
local gray="%F{7}"
|
||||||
else
|
else
|
||||||
local blue="%{$fg[cyan]%}"
|
local blue="%{$fg[cyan]%}"
|
||||||
local orange="%{$fg[yellow]%}"
|
local orange="%{$fg[yellow]%}"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue