(zsh) add auto detect theme

This commit is contained in:
jc 2024-09-06 14:02:19 -04:00
commit 3e48f59235
No known key found for this signature in database

View file

@ -61,7 +61,7 @@ sf() {
# fuzzy cd into specific folders # fuzzy cd into specific folders
fcd() { fcd() {
local selected_dir=$({ local selected_dir=$({
echo "$HOME/.config" find "$HOME/.config" -type d -maxdepth 1
echo "$HOME/Documents/Obsidian Vault" echo "$HOME/Documents/Obsidian Vault"
find "$HOME/ghq" -mindepth 2 -maxdepth 2 -type d find "$HOME/ghq" -mindepth 2 -maxdepth 2 -type d
ls -d -1 "$HOME/"/*/ | grep -v \.git ls -d -1 "$HOME/"/*/ | grep -v \.git
@ -161,18 +161,46 @@ PS1="%n@%m:%~ $ "
unset color_prompt unset color_prompt
# setup kitty, it will export TERM_COLOR_MODE (can be light or dark) # setup terminal stuff
# source ~/.config/kitty/setup.sh # determine initial terminal color mode
# function to toggle kitty terminal theme TERM_COLOR_MODE=dark
# toggle_theme() { command -v asadesuka > /dev/null 2>&1
# if [ "$TERM_COLOR_MODE" == "light" ]; then if [ $? -eq 0 ]; then
# export TERM_COLOR_MODE=dark IS_ASA=$(asadesuka -offset 30)
# kitten @ set-colors --all "$HOME/.config/kitty/dark.conf" if [ $IS_ASA = "true" ]; then
# else TERM_COLOR_MODE=light
# export TERM_COLOR_MODE=light fi
# kitten @ set-colors --all "$HOME/.config/kitty/light.conf" else
# fi CURRENT_HOUR=$(date +"%H")
# } SEVEN_AM=7
SEVEN_PM=19
if [ $CURRENT_HOUR -ge $SEVEN_AM ] && [ $CURRENT_HOUR -lt $SEVEN_PM ]; then
TERM_COLOR_MODE=light
fi
fi
export TERM_COLOR_MODE
# set the terminal color theme
USE_TERM=alacritty
if [ $TERM_COLOR_MODE = "light" ]; then
if [ $USE_TERM = "kitty" ]; then
kitten @ set-colors --all "$HOME/.config/kitty/light.conf"
fi
if [ $USE_TERM = "alacritty" ]; then
theme_link="$HOME/.config/alacritty/theme.toml"
rm -rf "$theme_link"
ln -s "$HOME/ghq/alacritty/alacritty-theme/themes/catppuccin_latte.toml" "$theme_link"
fi
else
if [ $USE_TERM = "kitty" ]; then
kitten @ set-colors --all "$HOME/.config/kitty/dark.conf"
fi
if [ $USE_TERM = "alacritty" ]; then
theme_link="$HOME/.config/alacritty/theme.toml"
rm -r "$theme_link"
ln -s "$HOME/ghq/alacritty/alacritty-theme/themes/catppuccin_mocha.toml" "$theme_link"
fi
fi
type -p curl >/dev/null || echo -e "$WARNING curl is not installed" type -p curl >/dev/null || echo -e "$WARNING curl is not installed"