-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathterminal-theme-picker-preview
More file actions
executable file
·65 lines (59 loc) · 3.13 KB
/
terminal-theme-picker-preview
File metadata and controls
executable file
·65 lines (59 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env zsh
# Called by terminal-theme-picker fzf --preview with theme name as $1
theme="$1"
ALACRITTY_THEMES_DIR="$HOME/.config/alacritty/themes"
TMUX_THEMES_DIR="$HOME/.config/tmux/themes"
ALACRITTY_CURRENT="$HOME/.config/alacritty/current-theme.toml"
toml="$ALACRITTY_THEMES_DIR/${theme}.toml"
# Apply alacritty colors live
if [[ -f "$toml" ]]; then
cp "$toml" "$ALACRITTY_CURRENT" 2>/dev/null
args=()
section=""
while IFS= read -r line; do
if [[ "$line" =~ '^\[(.+)\]$' ]]; then
section="${match[1]}"
continue
fi
if [[ "$line" =~ '^([a-z]+)[[:space:]]*=[[:space:]]*"(#[0-9a-fA-F]+)"' ]]; then
args+=("${section}.${match[1]}=\"${match[2]}\"")
fi
done < "$toml"
(( ${#args} > 0 )) && alacritty msg config "${args[@]}" 2>/dev/null
fi
# Apply tmux theme
if [[ -n "$TMUX" ]] && [[ -f "$TMUX_THEMES_DIR/${theme}.conf" ]]; then
tmux source-file "$TMUX_THEMES_DIR/${theme}.conf"
fi
# Apply neovim colorscheme to all running instances
nvim_cmd=""
case "$theme" in
gruvbox-dark) nvim_cmd=":lua require('gruvbox').setup({contrast=''})<CR>:set background=dark<CR>:colorscheme gruvbox<CR>" ;;
gruvbox-dark-hard) nvim_cmd=":lua require('gruvbox').setup({contrast='hard'})<CR>:set background=dark<CR>:colorscheme gruvbox<CR>" ;;
gruvbox-dark-soft) nvim_cmd=":lua require('gruvbox').setup({contrast='soft'})<CR>:set background=dark<CR>:colorscheme gruvbox<CR>" ;;
gruvbox-material) nvim_cmd=":let g:gruvbox_material_background='medium'<CR>:set background=dark<CR>:colorscheme gruvbox-material<CR>" ;;
gruvbox-material-hard) nvim_cmd=":let g:gruvbox_material_background='hard'<CR>:set background=dark<CR>:colorscheme gruvbox-material<CR>" ;;
gruvbox-material-soft) nvim_cmd=":let g:gruvbox_material_background='soft'<CR>:set background=dark<CR>:colorscheme gruvbox-material<CR>" ;;
nord) nvim_cmd=":colorscheme nordic<CR>" ;;
nordic) nvim_cmd=":colorscheme nordic<CR>" ;;
kanagawa-wave) nvim_cmd=":colorscheme kanagawa-wave<CR>" ;;
kanagawa-dragon) nvim_cmd=":colorscheme kanagawa-dragon<CR>" ;;
everforest-hard) nvim_cmd=":let g:everforest_background='hard'<CR>:set background=dark<CR>:colorscheme everforest<CR>" ;;
everforest-medium) nvim_cmd=":let g:everforest_background='medium'<CR>:set background=dark<CR>:colorscheme everforest<CR>" ;;
everforest-soft) nvim_cmd=":let g:everforest_background='soft'<CR>:set background=dark<CR>:colorscheme everforest<CR>" ;;
darkearth) nvim_cmd=":colorscheme darkearth<CR>" ;;
tokyo-night) nvim_cmd=":colorscheme tokyonight-night<CR>" ;;
tokyonight-storm) nvim_cmd=":colorscheme tokyonight-storm<CR>" ;;
tokyonight-moon) nvim_cmd=":colorscheme tokyonight-moon<CR>" ;;
esac
if [[ -n "$nvim_cmd" ]]; then
for sock in /tmp/nvim*.sock(N) /tmp/nvim-*.sock(N) "${TMPDIR}nvim.${USER}"/**/*.0(N); do
[[ -S "$sock" ]] || continue
nvim --server "$sock" --remote-send "$nvim_cmd" 2>/dev/null
done
fi
# Show theme info in preview pane
echo "Theme: $theme"
echo ""
echo "--- Alacritty colors ---"
grep -v '^#' "$toml" 2>/dev/null | grep -v '^$'