Skip to content

Instantly share code, notes, and snippets.

@agzam
Created October 23, 2025 20:58
Show Gist options
  • Select an option

  • Save agzam/197a63b37ce827bb95761069ffc85b3c to your computer and use it in GitHub Desktop.

Select an option

Save agzam/197a63b37ce827bb95761069ffc85b3c to your computer and use it in GitHub Desktop.
Quickly change kitty color theme
# fzf-driven kitty theme changer
# usage: ,kitty-theme light|dark
,kitty-theme() {
local mode="$1"
[[ -z "$mode" ]] && mode="all"
local original_theme=""
if [[ -f ~/.config/kitty/current-theme.conf ]]; then
original_theme=$(head -1 ~/.config/kitty/current-theme.conf | grep "^# Theme: " | sed 's/# Theme: //')
[[ -n "$original_theme" ]] && echo "Current theme: $original_theme"
fi
local jq_filter='.[].name'
if [[ "$mode" == "dark" ]]; then
jq_filter='.[] | select(.is_dark == true) | .name'
elif [[ "$mode" == "light" ]]; then
jq_filter='.[] | select(.is_dark != true) | .name'
fi
local theme
theme=$(curl -s https://raw.githubusercontent.com/kovidgoyal/kitty-themes/master/themes.json | \
jq -r "$jq_filter" | \
fzf --height 20 \
--preview 'kitten themes --reload-in=parent {}')
local fzf_exit_code=$?
if [[ $fzf_exit_code -eq 0 ]] && [[ -n "$theme" ]]; then
kitten themes --reload-in=all "$theme"
sed -i '' '1s/^/# Theme: '"$theme"'\n/' ~/.config/kitty/current-theme.conf
echo "Theme changed to: $theme"
else
if [[ -n "$original_theme" ]]; then
kitten themes --reload-in=parent "$original_theme"
echo "Theme restored to: $original_theme"
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment