Skip to content

Instantly share code, notes, and snippets.

@azdanov
Last active January 14, 2024 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azdanov/1e15c6842d832ac416236bb43964b7e6 to your computer and use it in GitHub Desktop.
Save azdanov/1e15c6842d832ac416236bb43964b7e6 to your computer and use it in GitHub Desktop.
Change background in fish automatically
function change_background --argument mode_setting
# https://arslan.io/2021/02/15/automatic-dark-mode-for-terminal-applications/
# change background to the given mode. If mode is missing,
# we try to deduct it from the system settings.
set -l mode "light" # default value
if test -z $mode_setting
set -l val (defaults read -g AppleInterfaceStyle) >/dev/null
if test $status -eq 0
set mode "dark"
end
else
switch $mode_setting
case light
osascript -l JavaScript -e "Application('System Events').appearancePreferences.darkMode = false" >/dev/null
set mode "light"
case dark
osascript -l JavaScript -e "Application('System Events').appearancePreferences.darkMode = true" >/dev/null
set mode "dark"
end
end
# change fish theme
switch $mode
case dark
yes | fish_config theme save "Catppuccin Macchiato"
case light
yes | fish_config theme save "Catppuccin Latte"
end
# change bat theme
switch $mode
case dark
set -Ux BAT_THEME "Catppuccin-macchiato"
case light
set -Ux BAT_THEME "Catppuccin-latte"
end
# change LS_COLORS
switch $mode
case dark
set -Ux LS_COLORS (vivid generate catppuccin-macchiato)
case light
set -Ux LS_COLORS (vivid generate catppuccin-latte)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment