Add shell auto-completion for zsh, bash, and fish

- completions/_ssr            zsh #compdef completion using _arguments/_values
- completions/ssr.bash        bash complete -F function (works with bash-completion@2)
- completions/ssr.fish        fish completions with __ssr_needs_subcmd predicates
- bin/ssr-completions         install/uninstall/status subcommand
                              - auto-detects $SHELL, --shell zsh|bash|fish|all
                              - symlinks into user-scoped paths (no sudo):
                                ~/.zsh/completions/_ssr
                                ~/.local/share/bash-completion/completions/ssr
                                ~/.config/fish/completions/ssr.fish
                              - prints fpath/bash-completion setup hints if not configured
- bin/ssr                     dispatcher knows `completions`; help line added
- bin/ssr-install             offers completion install after schedule prompt
- README                      Shell completions section, command list, layout entry

Verified:
- zsh -n  on _ssr        OK; autoload registers function
- bash -n on ssr.bash    OK; `complete -p ssr` returns the registration after source
- end-to-end install/status/uninstall against an ephemeral $HOME

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-11 16:16:22 +02:00
parent 69541209dc
commit c1848f66e8
7 changed files with 383 additions and 1 deletions
+31
View File
@@ -52,6 +52,7 @@ ssr restore [Brewfile] Restore the machine; Brewfile defaults to the cloud cop
ssr update [--dry-run] Pull latest ssr code, refresh launchd if needed
ssr schedule on|off Enable/disable the daily launchd job
ssr config show|edit Show or edit the active config
ssr completions install Install zsh/bash/fish tab-completion
ssr status Show config, cloud target, last sync, schedule state
ssr version Print version
```
@@ -124,6 +125,31 @@ Config lives in `~/.config/ssr/ssr.conf` (override with `--config` or `$SSR_CONF
---
## Shell completions
`ssr install` offers to install completions automatically. To do it manually later:
```bash
ssr completions install # detects $SHELL
ssr completions install --shell all # zsh + bash + fish
ssr completions status # show what's wired up
ssr completions uninstall --shell all
```
Targets (user-scoped, no sudo):
| Shell | Path |
|-------|------|
| zsh | `~/.zsh/completions/_ssr` |
| bash | `~/.local/share/bash-completion/completions/ssr` |
| fish | `~/.config/fish/completions/ssr.fish` |
For zsh, ensure `~/.zsh/completions` is on `$fpath` (the installer prints the snippet for `~/.zshrc` if it isn't already). For bash, you need [`bash-completion@2`](https://github.com/scop/bash-completion) sourced from your shell rc — Homebrew install path is also printed. Fish needs no extra setup.
After installation, open a fresh shell or `exec $SHELL` and `ssr <TAB>` lists the available commands.
---
## Scheduled sync
```bash
@@ -184,6 +210,7 @@ ssr update --dry-run # show what would change, don't pull
│ ├── ssr-restore # Rebuild a Mac from the backup
│ ├── ssr-schedule # launchd on/off/status
│ ├── ssr-config # show/edit/path
│ ├── ssr-completions # install zsh/bash/fish completions
│ └── ssr-status # state summary
├── lib/
│ ├── common.sh # Logging, validation, config loader
@@ -194,6 +221,10 @@ ssr update --dry-run # show what would change, don't pull
├── config/
│ ├── ssr.conf.example # Reference user config
│ └── macos-defaults.sh # Default macOS preferences
├── completions/
│ ├── _ssr # zsh
│ ├── ssr.bash # bash
│ └── ssr.fish # fish
├── launchd/
│ └── de.surke.ssr.sync.plist # Template for the scheduled agent
├── VERSION