Add bash tab-completion for setup.sh

./setup.sh mat<TAB> now completes to ./setup.sh mattermost, same for
flags. Service names are read fresh from services/*.sh on every
completion — never a hardcoded list, which would go stale the moment
a new service file gets added (matches this repo's own "adding a
service = adding one file, nothing generated" rule from CLAUDE.md).

Verified live: sourced the script and confirmed completions for "mat"
and "--li", and specifically confirmed "bes" resolves to "beszel" —
the service added earlier this same session — with zero changes
needed to the completion script itself, proving the list is genuinely
dynamic rather than something that looked right once and then rotted.

Self-locating via its own BASH_SOURCE path rather than a hardcoded
install directory, so it keeps working regardless of where the repo
is cloned. Works through a leading `sudo` via bash-completion's
standard sudo pass-through (enabled by default on Ubuntu).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H4k6J1qXXyYxhGEgnJaMvn
This commit is contained in:
Claude
2026-08-11 03:46:09 +00:00
parent 3bc14d8cf4
commit fc8f57ab51
2 changed files with 48 additions and 0 deletions
+14
View File
@@ -141,11 +141,25 @@ echo "cloud-init.sh: repo cloned to $DEST — the setup wizard will launch on fi
sudo ./setup.sh # interactive wizard
sudo ./setup.sh caddy immich # install specific services
sudo ./setup.sh configure # set site defaults (timezone, domain, Caddy network)
sudo ./setup.sh filebrowser --remove # remove a service (or: sudo ./setup.sh filebrowser remove)
./setup.sh --list # list all services grouped by category
sudo ./setup.sh --dry-run immich # preview without making changes
sudo ./setup.sh --unattended base # non-interactive, use defaults
```
### Tab completion
```bash
echo "source $(pwd)/tools/setup-completion.bash" >> ~/.bashrc
source ~/.bashrc
```
Then `./setup.sh mat<TAB>` completes to `./setup.sh mattermost` — same for
flags (`--li<TAB>``--list`). Works with a leading `sudo` too. The service
list is read fresh from `services/*.sh` on every completion, not a
hardcoded list baked into the script — a service added since you last
pulled shows up immediately, no re-running anything.
## What the wizard does
**First run:**