diff --git a/README.md b/README.md index 292a407..5651592 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,14 @@ The installer lets you pick a theme that is applied **consistently** across Neov | 4 | **Nord** | Arctic, muted blue-grey | | 5 | **Dracula** | High-contrast purple and green | +You can **switch themes at any time** after installation: + +```bash +archduino-theme # or just: theme +``` + +This updates Starship, Zellij, Lazygit, and NvChad in one step. + ### Supported Boards (out of the box) | Board | FQBN | @@ -183,6 +191,7 @@ All keybindings are under `a`: | `acb` | `arduino-cli board list` | | `lg` | `lazygit` | | `v` | `nvim` | +| `theme` | `archduino-theme` (switch colorscheme) | --- diff --git a/install.sh b/install.sh index 4b556ff..dd52f2d 100644 --- a/install.sh +++ b/install.sh @@ -102,6 +102,7 @@ echo " arduino-new my-project uno # scaffold a project" echo " adev # launch Arduino workspace" echo " av # compile in Neovim" echo " au # upload in Neovim" +echo " theme # switch colorscheme" echo "" warn "A reboot is recommended to apply all changes (shell, groups, PATH)." echo "" diff --git a/lib/scaffold.sh b/lib/scaffold.sh index ffce67d..f233ba1 100644 --- a/lib/scaffold.sh +++ b/lib/scaffold.sh @@ -135,4 +135,113 @@ void loop() { delay(1000); } INO -info "Scaffolding tool + templates created" +# ── Install theme files + theme switcher ───────────────────────── +mkdir -p ~/.config/archduino/themes +cp "$SCRIPT_DIR/lib/themes/"*.sh ~/.config/archduino/themes/ + +cat >~/.local/bin/archduino-theme <<'SWITCHER' +#!/bin/bash +set -euo pipefail + +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +RED='\033[0;31m' +BOLD='\033[1m' +NC='\033[0m' + +info() { echo -e "${GREEN}[✓]${NC} $1"; } +warn() { echo -e "${YELLOW}[!]${NC} $1"; } +error() { echo -e "${RED}[✗]${NC} $1"; exit 1; } + +THEMES_DIR="$HOME/.config/archduino/themes" +THEME_SAVE="$HOME/.config/archduino/theme" + +[[ ! -d "$THEMES_DIR" ]] && error "Theme files not found. Re-run the Archduino installer." + +THEME_FILES=(gruvbox catppuccin tokyonight nord dracula) + +# Load saved theme +saved_theme="" current_idx=0 +if [[ -f "$THEME_SAVE" ]]; then + saved_theme=$(cat "$THEME_SAVE") + for idx in "${!THEME_FILES[@]}"; do + [[ "${THEME_FILES[$idx]}" == "$saved_theme" ]] && current_idx=$((idx + 1)) && break + done +fi + +echo "" +echo -e " ${BOLD}Archduino Theme Switcher${NC}" +echo "" + +i=1 +for t in "${THEME_FILES[@]}"; do + source "$THEMES_DIR/$t.sh" + if [[ $i -eq $current_idx ]]; then + printf " %d) %s ${GREEN}(current)${NC}\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[@]}]: " choice + +if [[ -z "$choice" || ! "$choice" =~ ^[0-9]+$ ]] || ((choice < 1 || choice > ${#THEME_FILES[@]})); then + echo " No change." + exit 0 +fi + +if [[ $choice -eq $current_idx ]]; then + echo " Already using that theme." + exit 0 +fi + +selected="${THEME_FILES[$((choice - 1))]}" +source "$THEMES_DIR/$selected.sh" + +echo "" +info "Applying $THEME_DISPLAY_NAME..." + +# Starship +write_starship_config ~/.config/starship.toml +info "Starship updated" + +# Zellij +write_zellij_config ~/.config/zellij/config.kdl +info "Zellij updated" + +# Lazygit +write_lazygit_config ~/.config/lazygit/config.yml +info "Lazygit updated" + +# NvChad +NVIM_CFG="$HOME/.config/nvim" +if [[ -f "$NVIM_CFG/lua/chadrc.lua" ]]; then + cat >"$NVIM_CFG/lua/chadrc.lua" </dev/null || true + rm -rf ~/.cache/nvim/base46 2>/dev/null || true + info "NvChad updated (restart nvim to see changes)" +fi + +# Save choice +echo "$selected" > "$THEME_SAVE" + +echo "" +info "Theme switched to $THEME_DISPLAY_NAME" +warn "Restart Zellij and Neovim for full effect." +echo "" +SWITCHER +chmod +x ~/.local/bin/archduino-theme + +info "Scaffolding tool, templates, and theme switcher created" diff --git a/lib/shell-config.sh b/lib/shell-config.sh index 309d82a..9b4971e 100644 --- a/lib/shell-config.sh +++ b/lib/shell-config.sh @@ -26,6 +26,7 @@ alias acm="arduino-cli monitor" alias acb="arduino-cli board list" alias lg="lazygit" alias v="nvim" +alias theme="archduino-theme" # ── END ARCHDUINO ───────────────────────────────────────────────' if grep -q "ARCHDUINO CONFIG" ~/.zshrc 2>/dev/null; then