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:
marvin.dietermann
2026-04-10 12:46:48 +02:00
parent d5f57a3511
commit fbc1e60afc
4 changed files with 59 additions and 10 deletions

View File

@@ -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"
}