style: normalize whitespace and line endings in shell scripts
- Standardize indentation and spacing across install.sh and lib files - Fix line ending inconsistencies for better cross-platform compatibility - Improve curl flag usage in neovim.sh (-kLo with explicit temp path) - Add theme persistence functionality to remember user's colorscheme choice These changes improve code consistency and add the ability to save/restore the selected theme across sessions.
This commit is contained in:
@@ -2,29 +2,53 @@
|
||||
# Theme selection — sources the chosen theme file
|
||||
|
||||
THEMES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/themes"
|
||||
THEME_SAVE_FILE="$HOME/.config/archduino/theme"
|
||||
|
||||
THEME_FILES=(gruvbox catppuccin tokyonight nord dracula)
|
||||
|
||||
select_theme() {
|
||||
# Load previously saved theme as default
|
||||
local saved_theme="" default_idx=1
|
||||
if [[ -f "$THEME_SAVE_FILE" ]]; then
|
||||
saved_theme=$(cat "$THEME_SAVE_FILE")
|
||||
for idx in "${!THEME_FILES[@]}"; do
|
||||
if [[ "${THEME_FILES[$idx]}" == "$saved_theme" ]]; then
|
||||
default_idx=$((idx + 1))
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo " Select colorscheme:"
|
||||
echo ""
|
||||
|
||||
local i=1
|
||||
for t in "${THEME_FILES[@]}"; do
|
||||
source "$THEMES_DIR/$t.sh"
|
||||
printf " %d) %s\n" "$i" "$THEME_DISPLAY_NAME"
|
||||
if [[ $i -eq $default_idx && -n "$saved_theme" ]]; then
|
||||
printf " %d) %s (current)\n" "$i" "$THEME_DISPLAY_NAME"
|
||||
else
|
||||
printf " %d) %s\n" "$i" "$THEME_DISPLAY_NAME"
|
||||
fi
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
echo ""
|
||||
read -rp " Choice [1-${#THEME_FILES[@]}]: " theme_choice
|
||||
read -rp " Choice [1-${#THEME_FILES[@]}] (default: $default_idx): " theme_choice
|
||||
|
||||
# Default to 1 (Gruvbox) for invalid input
|
||||
if [[ ! "$theme_choice" =~ ^[0-9]+$ ]] || ((theme_choice < 1 || theme_choice > ${#THEME_FILES[@]})); then
|
||||
theme_choice=1
|
||||
# Default to saved theme (or Gruvbox) for empty/invalid input
|
||||
if [[ -z "$theme_choice" ]]; then
|
||||
theme_choice=$default_idx
|
||||
elif [[ ! "$theme_choice" =~ ^[0-9]+$ ]] || ((theme_choice < 1 || theme_choice > ${#THEME_FILES[@]})); then
|
||||
theme_choice=$default_idx
|
||||
fi
|
||||
|
||||
local selected="${THEME_FILES[$((theme_choice - 1))]}"
|
||||
source "$THEMES_DIR/$selected.sh"
|
||||
|
||||
# Persist choice for next run
|
||||
mkdir -p "$(dirname "$THEME_SAVE_FILE")"
|
||||
echo "$selected" > "$THEME_SAVE_FILE"
|
||||
|
||||
info "Selected theme: $THEME_DISPLAY_NAME"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user