#!/bin/zsh # Required parameters: # @raycast.schemaVersion 1 # @raycast.title Theme Switcher # @raycast.mode silent # @raycast.argument1 { "type": "dropdown","placeholder":"Theme", "data": [{"title": "Catppuccin Frappe", "value": "catppuccin-frappe"},{"title": "Catppuccin Latte", "value": "catppuccin-latte"},{"title": "Gruvbox Dark", "value": "gruvbox-dark"},{"title": "Gruvbox Light", "value": "gruvbox-light"}]} # #Ignore errors set +e terminal_theme_name="" zsh_theme_name="" background_color="" nvim_color_scheme="" tmux_bar_unfocused_fg="" tmux_bar_focused_bg="" tmux_bar_focused_fg="" change_common(){ #Change alacritty theme sed -i '' -e "s|import = \[\"~/.config/alacritty/themes/.*\"\]|import = [\"~/.config/alacritty/themes/${terminal_theme_name}.toml\"]|g" ~/.config/alacritty/alacritty.toml #Change zsh theme sed -i '' -e "s|source \$ZDOTDIR/themes/.*zsh|source \$ZDOTDIR/themes/${zsh_theme_name}.zsh|g" "$ZDOTDIR"/.zshrc #Reload zsh sessions pids=$(pgrep zsh) while IFS= read -r pid; do kill -USR1 "$pid" done <<< "$pids" #Change tmux theme sed -i '' -E "s/set -g status-bg .*$/set -g status-bg \"$background_color\"/" ~/.config/tmux/tmux_status_bar.conf sed -i '' -E "s/set -g @unfocused-fg .*$/set -g @unfocused-fg \"$tmux_bar_unfocused_fg\"/" ~/.config/tmux/tmux_status_bar.conf sed -i '' -E "s/set -g @focused-bg .*$/set -g @focused-bg \"$tmux_bar_focused_bg\"/" ~/.config/tmux/tmux_status_bar.conf sed -i '' -E "s/set -g @focused-fg .*$/set -g @focused-fg \"$tmux_bar_focused_fg\"/" ~/.config/tmux/tmux_status_bar.conf #Reload tmux sessions tmux source-file ~/.config/tmux/tmux.conf echo "vim.cmd('colorscheme ${nvim_color_scheme}')" >> ~/.config/nvim/lua/core/theme.lua for addr in $XDG_RUNTIME_DIR/nvim.*; do nvim --server $addr --remote-send ':colorscheme ${nvim_color_scheme}' || true done } case $1 in "catppuccin-latte") terminal_theme_name="catppuccin_latte" zsh_theme_name="catppuccin_latte" nvim_color_scheme="catppuccin-latte" background_color="#eff1f5" tmux_bar_unfocused_fg="#4c4f69" tmux_bar_focused_bg="#4c4f69" tmux_bar_focused_fg="#eff1f5" echo '' > ~/.config/nvim/lua/core/theme.lua change_common ;; "catppuccin-frappe") terminal_theme_name="catppuccin_frappe" zsh_theme_name="catppuccin_frappe" nvim_color_scheme="catppuccin-frappe" background_color="#303446" tmux_bar_unfocused_fg="#c6d0f5" tmux_bar_focused_bg="#c6d0f5" tmux_bar_focused_fg="#303446" echo '' > ~/.config/nvim/lua/core/theme.lua change_common ;; "gruvbox-dark") terminal_theme_name="gruvbox_dark" zsh_theme_name="gruvbox_dark" nvim_color_scheme="gruvbox-material" background_color="#1d2021" tmux_bar_unfocused_fg="#d4be98" tmux_bar_focused_bg="#d4be98" tmux_bar_focused_fg="#1d2021" nvim --server /tmp/nvim.pipe --remote-send ':lua vim.g.gruvbox_material_better_performance = 1' || true echo "vim.g.gruvbox_material_better_performance = 1" > ~/.config/nvim/lua/core/theme.lua nvim --server /tmp/nvim.pipe --remote-send ':lua vim.g.gruvbox_material_background = "hard"' || true echo "vim.g.gruvbox_material_background = 'hard'" >> ~/.config/nvim/lua/core/theme.lua nvim --server /tmp/nvim.pipe --remote-send ':lua vim.g.gruvbox_material_foreground = "original"' || true echo "vim.g.gruvbox_material_foreground = 'original'" >> ~/.config/nvim/lua/core/theme.lua nvim --server /tmp/nvim.pipe --remote-send ':lua vim.opt.background = "dark"' || true echo "vim.opt.background = 'dark'" >> ~/.config/nvim/lua/core/theme.lua #Change kitty theme kitten themes --reload-in=all Gruvbox Dark change_common ;; "gruvbox-light") terminal_theme_name="gruvbox_light" zsh_theme_name="gruvbox_light" nvim_color_scheme="gruvbox-material" background_color="#f2e5bc" tmux_bar_unfocused_fg="#654735" tmux_bar_focused_bg="#654735" tmux_bar_focused_fg="#f2e5bc" nvim --server /tmp/nvim.pipe --remote-send ':lua vim.g.gruvbox_material_better_performance = 1' || true echo "vim.g.gruvbox_material_better_performance = 1" > ~/.config/nvim/lua/core/theme.lua nvim --server /tmp/nvim.pipe --remote-send ':lua vim.g.gruvbox_material_background = "soft"' || true echo "vim.g.gruvbox_material_background = 'soft'" >> ~/.config/nvim/lua/core/theme.lua nvim --server /tmp/nvim.pipe --remote-send ':lua vim.g.gruvbox_material_foreground = "original"' || true echo "vim.g.gruvbox_material_foreground = 'original'" >> ~/.config/nvim/lua/core/theme.lua nvim --server /tmp/nvim.pipe --remote-send ':lua vim.opt.background = "light"' || true echo "vim.opt.background = 'light'" >> ~/.config/nvim/lua/core/theme.lua #Change kitty theme kitten themes --reload-in=all Gruvbox Light change_common ;; esac