Files
rootiest 261e663e97 feat(auto-pull): opt-in background fast-forward for registered repos
Add a C2-guarded PWD handler that background fast-forwards the fish-config
repo (baseline) plus any repos in a machine-local registry. Safety is
guaranteed by _auto_pull_sync: clean tree + has-upstream + --ff-only, else
no-op. Never rebases, merges, or overwrites work.

- conf.d/auto-pull.fish: --on-variable PWD handler, throttled to fire once
  per repo entry; spawns a --no-config child to run the worker
- functions/_auto_pull_sync.fish: the ff-only worker (safe on any branch)
- functions/auto-pull.fish: add/remove/list/status registry management,
  usable even when C2 is disabled
- completions/auto-pull.fish: subcommand + registered-repo completions

Registry lives at ~/.config/.user-dots/fish/auto-pull.list (machine-local,
never committed).
2026-06-19 02:21:21 -04:00

34 lines
1.3 KiB
Fish

# Copyright (C) 2026 Rootiest
# SPDX-License-Identifier: AGPL-3.0-or-later
# Completions for the `auto-pull` registry command.
function __auto_pull_registered
set -l list "$XDG_CONFIG_HOME/.user-dots/fish/auto-pull.list"
test -r "$list"; or return
for l in (command cat "$list" 2>/dev/null)
test -n "$l"; or continue
printf '%s\t%s\n' (path basename "$l") "$l"
end
end
set -l subcmds list add remove status
# Subcommands (only as the first argument).
complete -c auto-pull -f -n "not __fish_seen_subcommand_from $subcmds" \
-a list -d 'Show registered repos'
complete -c auto-pull -f -n "not __fish_seen_subcommand_from $subcmds" \
-a add -d "Register a repo (default: current)"
complete -c auto-pull -f -n "not __fish_seen_subcommand_from $subcmds" \
-a remove -d 'Unregister a repo'
complete -c auto-pull -f -n "not __fish_seen_subcommand_from $subcmds" \
-a status -d 'Show enabled state and registry path'
complete -c auto-pull -f -n "not __fish_seen_subcommand_from $subcmds" \
-s h -l help -d 'Show help'
# `add` takes a directory path.
complete -c auto-pull -n "__fish_seen_subcommand_from add" -a '(__fish_complete_directories)'
# `remove` completes registered repo basenames.
complete -c auto-pull -f -n "__fish_seen_subcommand_from remove" -a '(__auto_pull_registered)'