dotfiles v1.0.3

This commit is contained in:
Your Name
2026-06-19 20:04:27 +00:00
parent 9ab72703ad
commit 5d583e8413
3 changed files with 53 additions and 30 deletions

View File

@@ -38,7 +38,7 @@
# DOTFILES_DIR holds the template files; DOTFILES_BACKUP_DIR holds backups # DOTFILES_DIR holds the template files; DOTFILES_BACKUP_DIR holds backups
# and the last-update-check timestamp. # and the last-update-check timestamp.
set -g DOTFILES_VERSION "1.0.2" set -g DOTFILES_VERSION "1.0.3"
# --- Remote repository (set this to enable auto-updates) -------------------- # --- Remote repository (set this to enable auto-updates) --------------------
# Example: # Example:

View File

@@ -61,7 +61,7 @@ function dotfiles -d "Manage dotfiles and self-update system"
dotfiles_version dotfiles_version
case status case status
dotfiles_status dotfiles_status $argv[2..]
case init case init
# `dotfiles init` → init all # `dotfiles init` → init all

View File

@@ -9,11 +9,14 @@
# #
# What this script does: # What this script does:
# 1. Checks prerequisites: Fish shell, Git, and a few common tools # 1. Checks prerequisites: Fish shell, Git, and a few common tools
# 2. Clones the dotfiles repository (default: git@gitssh.toomuchtaco.net:taco/dots.git) # 2. Tries SSH clone (git@gitssh.toomuchtaco.net:taco/dots.git); falls back
# to HTTPS (https://git.toomuchtaco.net/taco/dots.git) and rewrites the
# remote origin to SSH so future pushes use the right URL
# 3. Replaces or updates ~/.config/fish/ with the contents of the repo # 3. Replaces or updates ~/.config/fish/ with the contents of the repo
# 4. Sources the new config and runs `dotfiles init` to install templates # 4. Sources the new config and runs `dotfiles init` to install templates
# (~/.tmux.conf, ~/.gitconfig, ~/.config/starship.toml, etc.) # (~/.tmux.conf, ~/.gitconfig, ~/.config/starship.toml, etc.)
# 5. Prints next steps # 5. Warns if SSH key is needed and points to the gitea_key helper
# 6. Prints next steps
# #
# You can pass a custom repo URL as the first argument: # You can pass a custom repo URL as the first argument:
# #
@@ -25,10 +28,12 @@
# Configuration # Configuration
# ────────────────────────────────────────────────────────────────────────────── # ──────────────────────────────────────────────────────────────────────────────
# Default repository URL (overridable via first argument). # Default repository URLs (overridable via first argument).
set -l REPO_URL "git@gitssh.toomuchtaco.net:taco/dots.git" set -l SSH_REPO "git@gitssh.toomuchtaco.net:taco/dots.git"
set -l HTTPS_REPO "https://git.toomuchtaco.net/taco/dots.git"
if set -q argv[1] if set -q argv[1]
set REPO_URL "$argv[1]" set SSH_REPO "$argv[1]"
set HTTPS_REPO "$argv[1]"
end end
set -l REPO_BRANCH "main" set -l REPO_BRANCH "main"
@@ -93,31 +98,33 @@ end
# 2. Fetch the repository # 2. Fetch the repository
# ────────────────────────────────────────────────────────────────────────────── # ──────────────────────────────────────────────────────────────────────────────
_step "2/5" "Fetching dotfiles from $REPO_URL ..." _step "2/5" "Fetching dotfiles ..."
set -l tmpdir (mktemp -d) set -l tmpdir (mktemp -d)
set -l CLONED_SSH 0
if command git clone --branch "$REPO_BRANCH" "$REPO_URL" "$tmpdir" 2>/dev/null # Try SSH first (private repo, full read/write access).
echo "$GRN$RST Repository cloned." echo " Trying SSH: $SSH_REPO"
if command git clone --branch "$REPO_BRANCH" "$SSH_REPO" "$tmpdir"
echo "$GRN$RST Repository cloned via SSH."
set CLONED_SSH 1
else else
# Clone failed — the repo might not exist yet, or this is a first install. echo "$YLW ⚠ SSH clone failed.$RST"
# Print the error and let the user decide. echo " (SSH key may not be loaded — this is expected on first install)"
echo "$YLW ⚠ Clone failed.$RST"
echo " This might mean:"
echo " - The repository doesn't exist yet"
echo " - SSH key is not loaded (ssh-add -l)"
echo " - No network access"
echo "" echo ""
echo " Attempting alternative clone (HTTPS fallback) ..."
# Try HTTPS fallback. # Fall back to HTTPS (public read-only access).
set -l https_url (string replace "git@gitssh.toomuchtaco.net:" "https://git.toomuchtaco.net/" "$REPO_URL" | string replace ".git" "") echo " Trying HTTPS: $HTTPS_REPO"
if command git clone --branch "$REPO_BRANCH" "$https_url" "$tmpdir" 2>/dev/null if command git clone --branch "$REPO_BRANCH" "$HTTPS_REPO" "$tmpdir"
echo "$GRN$RST Repository cloned via HTTPS." echo "$GRN$RST Repository cloned via HTTPS."
echo ""
echo " Switching remote origin to SSH path for future pushes ..."
command git -C "$tmpdir" remote set-url origin "$SSH_REPO"
echo "$GRN$RST Remote origin updated to: $SSH_REPO"
else else
echo "$RED ERROR: All clone methods failed.$RST" echo "$RED ERROR: All clone methods failed.$RST"
echo " Manually clone the repo and re-run this script:" echo " Manually clone the repo and re-run this script:"
echo " git clone $REPO_URL $FISH_CONFIG_DIR" echo " git clone $SSH_REPO $FISH_CONFIG_DIR"
command rm -rf "$tmpdir" command rm -rf "$tmpdir"
exit 1 exit 1
end end
@@ -173,9 +180,9 @@ if test -f "$FISH_CONFIG_DIR/functions/dotfiles.fish"
source "$FISH_CONFIG_DIR/functions/dotfiles.fish" source "$FISH_CONFIG_DIR/functions/dotfiles.fish"
end end
# Persist the repo URL so `dotfiles publish` and `dotfiles sync` work. # Persist the SSH repo URL so `dotfiles publish` and `dotfiles sync` work.
if test -n "$REPO_URL" if test -n "$SSH_REPO"
dotfiles repo "$REPO_URL" 2>/dev/null dotfiles repo "$SSH_REPO" 2>/dev/null
end end
# Run init for every managed template. # Run init for every managed template.
@@ -205,12 +212,28 @@ echo "$BOLD━━━━━━━━━━━━━━━━━━━━━━━
echo "" echo ""
echo " $YLW""Next steps:$RST" echo " $YLW""Next steps:$RST"
echo "" echo ""
echo " 1. Start a new fish shell or run: exec fish" echo " $(set_color green)1.$RST Start a new fish shell: exec fish"
echo " 2. Check status of managed files: dotfiles status" echo " $(set_color green)2.$RST Check managed files: dotfiles status"
echo " 3. Edit a dotfile: dotfiles edit tmux" echo " $(set_color green)3.$RST Edit a dotfile: dotfiles edit tmux"
echo " 4. Pull remote updates: dotfiles sync" echo " $(set_color green)4.$RST Pull remote updates: dotfiles sync"
echo " 5. Push your changes: dotfiles publish" echo " $(set_color green)5.$RST Push your changes: dotfiles publish"
echo "" echo ""
# If we fell back to HTTPS, SSH auth isn't set up yet.
if test "$CLONED_SSH" -eq 0
echo " $YLW""⚠ SSH key required for push access$RST"
echo ""
echo " To push changes, you need an SSH key set up for Gitea."
echo " Run this built-in helper to generate one and configure SSH:"
echo ""
echo " $(set_color --bold)gitea_key$RST"
echo ""
echo " It will create ~/.ssh/id_ed25519_gitea, update ~/.ssh/config,"
echo " and print the public key for you to add at:"
echo " $(set_color cyan)https://git.toomuchtaco.net/user/settings/keys$RST"
echo ""
end
echo " $YLW""New to the dotfiles system?$RST" echo " $YLW""New to the dotfiles system?$RST"
echo " dotfiles help" echo " dotfiles help"
echo "" echo ""