This commit is contained in:
2026-04-22 20:07:03 +02:00
parent 8b6ff74a58
commit dd1adb373f
2 changed files with 41 additions and 27 deletions

0
.codex Normal file
View File

View File

@@ -20,6 +20,8 @@ command_exists() {
command -v "$1" >/dev/null 2>&1 command -v "$1" >/dev/null 2>&1
} }
AUTO_INSTALL_DEPS=0
find_ssh_key_in_dir() { find_ssh_key_in_dir() {
local ssh_dir="$1" local ssh_dir="$1"
local key_file="" local key_file=""
@@ -46,7 +48,6 @@ wait_for_ssh_key() {
local preferred_path="$1" local preferred_path="$1"
local ssh_dir="$HOME_DIR/.ssh" local ssh_dir="$HOME_DIR/.ssh"
local detected_key="" local detected_key=""
local reply=""
mkdir -p "$ssh_dir" mkdir -p "$ssh_dir"
chmod 700 "$ssh_dir" chmod 700 "$ssh_dir"
@@ -64,22 +65,8 @@ wait_for_ssh_key() {
info "Waiting for an SSH key to appear in $ssh_dir" info "Waiting for an SSH key to appear in $ssh_dir"
printf 'Create the key in another terminal, then press Enter here to continue.\n' printf 'Create the key in another terminal, then press Enter here to continue.\n'
printf 'Expected path: %s (with matching .pub file)\n' "$preferred_path" printf 'Expected path: %s (with matching .pub file)\n' "$preferred_path"
read -r -p "Press Enter once you have generated the SSH key... "
while true; do printf '%s' "$preferred_path"
read -r -p "Press Enter once you have generated the SSH key... " reply
if [[ -f "$preferred_path" && -f "$preferred_path.pub" ]]; then
printf '%s' "$preferred_path"
return 0
fi
if detected_key="$(find_ssh_key_in_dir "$ssh_dir")"; then
printf '%s' "$detected_key"
return 0
fi
warn "No key was found. Please press Enter when you have created the key."
done
} }
prompt_yes_no() { prompt_yes_no() {
@@ -107,6 +94,18 @@ prompt_yes_no() {
done done
} }
prompt_dependency_yes_no() {
local prompt="$1"
local default="${2:-Y}"
if [[ "$AUTO_INSTALL_DEPS" -eq 1 ]]; then
printf '%s\n' "$prompt [auto-yes]"
return 0
fi
prompt_yes_no "$prompt" "$default"
}
prompt_value() { prompt_value() {
local prompt="$1" local prompt="$1"
local default="${2:-}" local default="${2:-}"
@@ -264,7 +263,11 @@ cd "$HOME_DIR"
info "Interactive Arch post-install" info "Interactive Arch post-install"
if prompt_yes_no "Update the system first?" "Y"; then if prompt_yes_no "Auto-install dependency packages and tooling without per-item prompts?" "N"; then
AUTO_INSTALL_DEPS=1
fi
if prompt_dependency_yes_no "Update the system first?" "Y"; then
info "Updating system" info "Updating system"
sudo pacman -Syu --noconfirm sudo pacman -Syu --noconfirm
fi fi
@@ -307,21 +310,21 @@ declare -a PACMAN_PACKAGES=(
info "Package selection" info "Package selection"
for package in "${PACMAN_PACKAGES[@]}"; do for package in "${PACMAN_PACKAGES[@]}"; do
if prompt_yes_no "Install package '$package'?" "Y"; then if prompt_dependency_yes_no "Install package '$package'?" "Y"; then
install_pacman_package "$package" install_pacman_package "$package"
fi fi
done done
if prompt_yes_no "Install AUR helper 'yay'?" "Y"; then if prompt_dependency_yes_no "Install AUR helper 'yay'?" "Y"; then
install_yay install_yay
fi fi
if command_exists yay && prompt_yes_no "Install AUR package 'zen-browser-bin'?" "Y"; then if command_exists yay && prompt_dependency_yes_no "Install AUR package 'zen-browser-bin'?" "Y"; then
info "Installing zen-browser-bin" info "Installing zen-browser-bin"
yay -S --needed --noconfirm zen-browser-bin yay -S --needed --noconfirm zen-browser-bin
fi fi
if prompt_yes_no "Install ble.sh?" "Y"; then if prompt_dependency_yes_no "Install ble.sh?" "Y"; then
if [[ ! -f "$HOME_DIR/.local/share/blesh/ble.sh" ]]; then if [[ ! -f "$HOME_DIR/.local/share/blesh/ble.sh" ]]; then
info "Installing ble.sh" info "Installing ble.sh"
git clone --recursive --depth 1 --shallow-submodules https://github.com/akinomyoga/ble.sh.git "$TMP_DIR/ble.sh" git clone --recursive --depth 1 --shallow-submodules https://github.com/akinomyoga/ble.sh.git "$TMP_DIR/ble.sh"
@@ -335,7 +338,7 @@ if prompt_yes_no "Install ble.sh?" "Y"; then
append_if_missing '[ -f "$HOME/.config/blerc" ] && source "$HOME/.config/blerc"' "$HOME_DIR/.blerc" append_if_missing '[ -f "$HOME/.config/blerc" ] && source "$HOME/.config/blerc"' "$HOME_DIR/.blerc"
fi fi
if prompt_yes_no "Enable starship in ~/.bashrc?" "Y"; then if prompt_dependency_yes_no "Enable starship in ~/.bashrc?" "Y"; then
info "Configuring shell" info "Configuring shell"
append_if_missing 'eval "$(starship init bash)"' "$BASHRC" append_if_missing 'eval "$(starship init bash)"' "$BASHRC"
fi fi
@@ -354,8 +357,17 @@ if prompt_yes_no "Wait for an existing SSH key for git access?" "Y"; then
ssh_key_path="$(prompt_required_value "SSH key path:" "$HOME_DIR/.ssh/id_ed25519")" ssh_key_path="$(prompt_required_value "SSH key path:" "$HOME_DIR/.ssh/id_ed25519")"
ssh_key_path="$(wait_for_ssh_key "$ssh_key_path")" ssh_key_path="$(wait_for_ssh_key "$ssh_key_path")"
chmod 600 "$ssh_key_path" if [[ -f "$ssh_key_path" ]]; then
chmod 644 "$ssh_key_path.pub" chmod 600 "$ssh_key_path"
else
warn "Private key '$ssh_key_path' was not found; continuing without changing permissions"
fi
if [[ -f "$ssh_key_path.pub" ]]; then
chmod 644 "$ssh_key_path.pub"
else
warn "Public key '$ssh_key_path.pub' was not found; clipboard copy will be skipped"
fi
if prompt_yes_no "Add a git host to ~/.ssh/known_hosts?" "Y"; then if prompt_yes_no "Add a git host to ~/.ssh/known_hosts?" "Y"; then
git_host="$(prompt_required_value "Git host (for ssh-keyscan):")" git_host="$(prompt_required_value "Git host (for ssh-keyscan):")"
@@ -363,7 +375,9 @@ if prompt_yes_no "Wait for an existing SSH key for git access?" "Y"; then
fi fi
if prompt_yes_no "Copy the public SSH key to the clipboard?" "Y"; then if prompt_yes_no "Copy the public SSH key to the clipboard?" "Y"; then
if command_exists wl-copy; then if [[ ! -f "$ssh_key_path.pub" ]]; then
warn "Public key '$ssh_key_path.pub' is not available yet"
elif command_exists wl-copy; then
wl-copy <"$ssh_key_path.pub" wl-copy <"$ssh_key_path.pub"
info "Your public SSH key has been copied to the clipboard" info "Your public SSH key has been copied to the clipboard"
else else
@@ -395,7 +409,7 @@ if prompt_yes_no "Remap ThinkPad Alt to Super with keyd?" "Y"; then
fi fi
fi fi
if prompt_yes_no "Set up uv with Python 3.14 and global tools?" "Y"; then if prompt_dependency_yes_no "Set up uv with Python 3.14 and global tools?" "Y"; then
if command_exists uv; then if command_exists uv; then
info "Configuring uv" info "Configuring uv"
uv python install 3.14 uv python install 3.14