c1848f66e8
- 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>
53 lines
1.6 KiB
Bash
Executable File
53 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# ssr-install — local install: symlink CLI, seed config, optionally schedule.
|
|
|
|
set -euo pipefail
|
|
SSR_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
# shellcheck source=../lib/common.sh
|
|
source "$SSR_ROOT/lib/common.sh"
|
|
|
|
ssr::require_macos
|
|
|
|
PREFIX="${SSR_PREFIX:-$HOME/.local/bin}"
|
|
CONFIG_DIR="${SSR_CONFIG_DIR:-$HOME/.config/ssr}"
|
|
CONFIG_FILE="$CONFIG_DIR/ssr.conf"
|
|
|
|
ssr::log "Installing ssr"
|
|
ssr::log " prefix: $PREFIX"
|
|
ssr::log " config: $CONFIG_FILE"
|
|
|
|
ssr::ensure_dir "$PREFIX"
|
|
ssr::ensure_dir "$CONFIG_DIR"
|
|
|
|
# Symlink the main CLI so `ssr` works from anywhere.
|
|
ln -sfn "$SSR_ROOT/bin/ssr" "$PREFIX/ssr"
|
|
ssr::ok "Linked $PREFIX/ssr → $SSR_ROOT/bin/ssr"
|
|
|
|
# Seed config from the example (do not overwrite an existing user config).
|
|
if [[ ! -f "$CONFIG_FILE" ]]; then
|
|
cp "$SSR_ROOT/config/ssr.conf.example" "$CONFIG_FILE"
|
|
chmod 600 "$CONFIG_FILE"
|
|
ssr::ok "Seeded $CONFIG_FILE (chmod 600)"
|
|
else
|
|
ssr::log "Config already exists, leaving untouched: $CONFIG_FILE"
|
|
fi
|
|
|
|
# Path hint if PREFIX is not on PATH.
|
|
case ":$PATH:" in
|
|
*":$PREFIX:"*) ;;
|
|
*) ssr::warn "$PREFIX is not on your PATH — add it to your shell rc:"
|
|
echo " export PATH=\"$PREFIX:\$PATH\"" ;;
|
|
esac
|
|
|
|
# Offer to enable the scheduled sync.
|
|
if ssr::confirm "Enable daily scheduled sync (launchd)?" 30; then
|
|
"$SSR_ROOT/bin/ssr-schedule" on
|
|
fi
|
|
|
|
# Offer to install shell completions for the detected shell.
|
|
if ssr::confirm "Install shell completions for $(basename "${SHELL:-unknown}")?" 30; then
|
|
"$SSR_ROOT/bin/ssr-completions" install
|
|
fi
|
|
|
|
ssr::ok "Install complete. Run: ssr status"
|