From 8b9c5c70b2fd053c06f3a1ecd6981e0efcc3ee4e Mon Sep 17 00:00:00 2001 From: The_miro Date: Fri, 26 Jun 2026 09:05:00 +0200 Subject: [PATCH] feat(installer): add shell_rc preference to skip copying .*rcs to skel Adds a dialog (interactive + answerfile) letting the user choose whether to copy the dotfiles' .zshrc / .bashrc / .vimrc into /etc/skel, or leave system defaults in place. The choice is persisted as shell_rc in the answerfile JSON and respected by both the TUI installer and the generator. Co-Authored-By: Claude Sonnet 4.6 --- setup/generate-answerfile.sh | 13 ++++++++++++- setup/tui-install.sh | 26 ++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/setup/generate-answerfile.sh b/setup/generate-answerfile.sh index b9a1941..ba4a0d8 100644 --- a/setup/generate-answerfile.sh +++ b/setup/generate-answerfile.sh @@ -179,6 +179,7 @@ dialog --backtitle "$BACKTITLE" \ AF_COMPONENTS="" AF_DE="none" AF_APPS="" +AF_SHELL_RC="dotfiles" AF_COLOR_TEXT="" AF_COLOR_BG="" AF_COLOR_HIGHLIGHT="" @@ -294,6 +295,14 @@ if [[ "$AF_RUN_TUI" == "true" ]]; then "qemu" "QEMU/KVM full virt stack + virt-manager GUI" off \ 3>&1 1>&2 2>&3) || AF_APPS="" + # ── Shell RC preference ─────────────────────────────────────────────────── + AF_SHELL_RC=$(dialog --backtitle "$BACKTITLE" \ + --title " Shell Config for New Users " \ + --menu "\n Should new users on this machine inherit the dotfiles' rc files?\n (Controls what gets copied to /etc/skel)\n" 13 68 2 \ + "dotfiles" "Use the_miro's .zshrc / .bashrc / .vimrc from dotfiles" \ + "defaults" "Skip — use system defaults for new users" \ + 3>&1 1>&2 2>&3) || AF_SHELL_RC="defaults" + # ── Colorway ────────────────────────────────────────────────────────────── # Read defaults from repo colors.conf declare -A _cdef @@ -355,6 +364,7 @@ SUMMARY+=" Encrypt: $AF_ENCRYPT\n" SUMMARY+=" FIDO2 root: $AF_FIDO2_ROOT / FIDO2 user: $AF_FIDO2_USER\n" SUMMARY+=" Run TUI: $AF_RUN_TUI\n" [[ -n "$AF_DE" && "$AF_DE" != "none" ]] && SUMMARY+=" DE: $AF_DE\n" +SUMMARY+=" Shell rc: $AF_SHELL_RC\n" [[ -n "$AF_COLOR_TEXT" ]] && SUMMARY+=" Colors: custom\n" dialog --backtitle "$BACKTITLE" \ @@ -392,7 +402,8 @@ mkdir -p "$(dirname "$OUTPUT")" printf ' "run_tui": %s,\n' "$AF_RUN_TUI" printf ' "components": %s,\n' "$(_words_to_json_array "$AF_COMPONENTS")" printf ' "desktop_environment": %s,\n' "$(json_str "$AF_DE")" - printf ' "apps": %s' "$(_words_to_json_array "$AF_APPS")" + printf ' "apps": %s,\n' "$(_words_to_json_array "$AF_APPS")" + printf ' "shell_rc": %s' "$(json_str "$AF_SHELL_RC")" if [[ -n "$AF_COLOR_TEXT" ]]; then printf ',\n "colors": {\n' diff --git a/setup/tui-install.sh b/setup/tui-install.sh index a505da6..53e7ebb 100755 --- a/setup/tui-install.sh +++ b/setup/tui-install.sh @@ -246,6 +246,7 @@ AF_HOSTNAME="" AF_COMPONENTS="" AF_DE="none" AF_APPS="" +AF_SHELL_RC="dotfiles" AF_COLOR_TEXT="" AF_COLOR_BG="" AF_COLOR_HIGHLIGHT="" @@ -263,6 +264,7 @@ load_answerfile() { AF_COMPONENTS=$(jq -r '(.components // []) | join(" ")' "$ANSWERFILE") AF_DE=$(jq -r '.desktop_environment // "none"' "$ANSWERFILE") AF_APPS=$(jq -r '(.apps // []) | join(" ")' "$ANSWERFILE") + AF_SHELL_RC=$(jq -r '.shell_rc // "dotfiles"' "$ANSWERFILE") # Color values are optional; an empty string means "keep the repo default". AF_COLOR_TEXT=$(jq -r '.colors.COLOR_TEXT // ""' "$ANSWERFILE") AF_COLOR_BG=$(jq -r '.colors.COLOR_BG // ""' "$ANSWERFILE") @@ -519,6 +521,18 @@ else 3>&1 1>&2 2>&3) || SELECTED_APPS="" fi +# ── Shell RC preference ─────────────────────────────────────────────────────── +if $ANSWERFILE_MODE; then + SHELL_RC="$AF_SHELL_RC" +else + SHELL_RC=$(dialog --backtitle "$BACKTITLE" \ + --title " Shell Config for New Users " \ + --menu "\n Should new users on this machine inherit the dotfiles' rc files?\n (Controls what gets copied to /etc/skel)\n" 13 68 2 \ + "dotfiles" "Use the_miro's .zshrc / .bashrc / .vimrc from dotfiles" \ + "defaults" "Skip — use system defaults for new users" \ + 3>&1 1>&2 2>&3) || SHELL_RC="defaults" +fi + # ── Confirmation (interactive mode only) ────────────────────────────────────── if ! $ANSWERFILE_MODE; then # Build a human-readable summary of everything that will be installed so the @@ -530,6 +544,8 @@ if ! $ANSWERFILE_MODE; then [[ "$COMPONENTS" == *"svc"* ]] && SUMMARY+=" ✦ Core services\n" [[ "$COMPONENTS" == *"shell"* ]] && SUMMARY+=" ✦ Shell setup\n" [[ "$DE" != "none" && "$DE" != "" ]] && SUMMARY+=" ✦ Desktop environment: $DE\n" + [[ "$SHELL_RC" == "dotfiles" ]] && SUMMARY+=" ✦ Shell rc files → /etc/skel (dotfiles)\n" \ + || SUMMARY+=" ✦ Shell rc files → /etc/skel (system defaults)\n" if [[ -n "$SELECTED_APPS" ]]; then SUMMARY+="\n Applications:\n" @@ -831,11 +847,13 @@ if [[ -d "$HOME/.config" ]]; then # itself, making the merge non-destructive if /etc/skel/.config already exists. sudo cp -r "$HOME/.config/." /etc/skel/.config/ fi -# Copy themes, shell rc files, and vimrc only if they were actually created during install. [[ -d "$HOME/.themes" ]] && { sudo mkdir -p /etc/skel/.themes; sudo cp -r "$HOME/.themes/." /etc/skel/.themes/; } -[[ -f "$HOME/.zshrc" ]] && sudo cp "$HOME/.zshrc" /etc/skel/.zshrc -[[ -f "$HOME/.bashrc" ]] && sudo cp "$HOME/.bashrc" /etc/skel/.bashrc -[[ -f "$HOME/.vimrc" ]] && sudo cp "$HOME/.vimrc" /etc/skel/.vimrc +# Copy shell rc files to skel only if the user opted in to the dotfiles configs. +if [[ "$SHELL_RC" == "dotfiles" ]]; then + [[ -f "$HOME/.zshrc" ]] && sudo cp "$HOME/.zshrc" /etc/skel/.zshrc + [[ -f "$HOME/.bashrc" ]] && sudo cp "$HOME/.bashrc" /etc/skel/.bashrc + [[ -f "$HOME/.vimrc" ]] && sudo cp "$HOME/.vimrc" /etc/skel/.vimrc +fi # ── Done ────────────────────────────────────────────────────────────────────── if $ANSWERFILE_MODE; then