Last active
January 14, 2024 11:41
-
-
Save azdanov/1e15c6842d832ac416236bb43964b7e6 to your computer and use it in GitHub Desktop.
Change background in fish automatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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