(bash) update bashrc to determine color mode instead of setup.sh

This commit is contained in:
jc 2024-08-07 17:04:02 -04:00
commit 9e50504a45
No known key found for this signature in database

View file

@ -116,8 +116,10 @@ sf() {
# fuzzy cd into specific folders # fuzzy cd into specific folders
fcd() { fcd() {
local selected_dir=$({ local selected_dir=$({
echo "$HOME/.config" echo "$HOME/.config/asa"
echo "$HOME/.config/alacritty"
echo "$HOME/.cache" echo "$HOME/.cache"
echo "$HOME/.cache/asadesuka"
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
@ -214,22 +216,62 @@ else
fi fi
unset color_prompt unset color_prompt
# setup terminal stuff
# determine initial terminal color mode
TERM_COLOR_MODE=dark
command -v asadesuka > /dev/null 2>&1
if [ $? -eq 0 ]; then
IS_ASA=$(asadesuka -offset=30)
if [ $IS_ASA == "true" ]; then
TERM_COLOR_MODE=light
fi
else
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 -r "$theme_link"
ln "$HOME/.config/alacritty/themes/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 "$HOME/.config/alacritty/themes/themes/catppuccin_mocha.toml" "$theme_link"
fi
fi
# setup kitty, it will export TERM_COLOR_MODE (can be light or dark) # setup kitty, it will export TERM_COLOR_MODE (can be light or dark)
source ~/.config/kitty/setup.sh # source ~/.config/kitty/setup.sh
# function to toggle kitty terminal theme # function to toggle kitty terminal theme
toggle_theme() { toggle_theme() {
# theme_link="$HOME/.config/alacritty/theme.toml" theme_link="$HOME/.config/alacritty/theme.toml"
# rm -r "$theme_link" rm -r "$theme_link"
if [ "$TERM_COLOR_MODE" == "light" ]; then if [ "$TERM_COLOR_MODE" == "light" ]; then
export TERM_COLOR_MODE=dark export TERM_COLOR_MODE=dark
# kitten @ set-colors --all "$HOME/.config/kitty/dark.conf" theme="catppuccin_latte"
# theme="catppuccin_latte"
else else
export TERM_COLOR_MODE=light export TERM_COLOR_MODE=light
# theme="catppuccin_mocha" theme="catppuccin_mocha"
fi fi
kitten @ set-colors --all "$HOME/.config/kitty/$TERM_COLOR_MODE.conf" # kitten @ set-colors --all "$HOME/.config/kitty/$TERM_COLOR_MODE.conf"
# ln "$HOME/.config/alacritty/themes/themes/$theme.toml" "$theme_link" ln "$HOME/.config/alacritty/themes/themes/$theme.toml" "$theme_link"
} }
type -p curl >/dev/null || echo -e "$WARNING curl is not installed" type -p curl >/dev/null || echo -e "$WARNING curl is not installed"