From 079c3e4f10aa4747344c5a8fc7778d5cbb250d00 Mon Sep 17 00:00:00 2001 From: Tommy Rantti Date: Sat, 26 Sep 2026 20:08:28 +0300 Subject: [PATCH] Remember Forgejo URL and key label across runs Persist the last-entered values to ~/.config/travel-bootstrap/config and offer them as the prompt default, so a re-run only needs Enter instead of retyping the same values every time. Co-Authored-By: Claude Sonnet 5 --- bootstrap.sh | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index b60f103..a89df29 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -50,17 +50,38 @@ preflight_env() { gather_config() { section "config" + local config_file="$HOME/.config/travel-bootstrap/config" + mkdir -p "$(dirname "$config_file")" + + local DEFAULT_FORGEJO_URL="" DEFAULT_KEY_NAME="" + if [ -f "$config_file" ]; then + # shellcheck disable=SC1090 + source "$config_file" + fi + if [ -z "${FORGEJO_URL:-}" ]; then - read -rp "Forgejo instance URL (e.g. https://git.example.com): " FORGEJO_URL + if [ -n "$DEFAULT_FORGEJO_URL" ]; then + read -rp "Forgejo instance URL [$DEFAULT_FORGEJO_URL]: " FORGEJO_URL + FORGEJO_URL="${FORGEJO_URL:-$DEFAULT_FORGEJO_URL}" + else + read -rp "Forgejo instance URL (e.g. https://git.example.com): " FORGEJO_URL + fi fi FORGEJO_URL="${FORGEJO_URL%/}" if [ -z "${KEY_NAME:-}" ]; then - read -rp "Label for this device's SSH key [travel-laptop]: " KEY_NAME + local key_default="${DEFAULT_KEY_NAME:-travel-laptop}" + read -rp "Label for this device's SSH key [$key_default]: " KEY_NAME + KEY_NAME="${KEY_NAME:-$key_default}" fi - KEY_NAME="${KEY_NAME:-travel-laptop}" KEYFILE="$HOME/.ssh/id_ed25519_${KEY_NAME}" + cat > "$config_file" <