From 6b55f5b76c9f794f90b1624db163fa935c049ef2 Mon Sep 17 00:00:00 2001 From: Dan Henton Date: Mon, 13 Apr 2026 21:00:25 +1200 Subject: [PATCH] add alias to installer --- README.md | 2 ++ cmd/opencode-worktree/main.go | 3 +++ docs/install.md | 7 +++++- install.sh | 41 +++++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2b0ea40..4ef3dba 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ For other install methods (Go, manual download, PATH troubleshooting), see the [ ## Usage +> **Shortcut:** The installer adds `ocwt` as a shell alias for `opencode-worktree` — use either interchangeably. + ### Start an agent task ```bash diff --git a/cmd/opencode-worktree/main.go b/cmd/opencode-worktree/main.go index 9983bcd..11db6ed 100644 --- a/cmd/opencode-worktree/main.go +++ b/cmd/opencode-worktree/main.go @@ -60,6 +60,9 @@ Merge Options: General: -h, --help Show this help message + +Alias: + The installer adds 'ocwt' as a shell alias for opencode-worktree. `) } diff --git a/docs/install.md b/docs/install.md index 066bdb4..8876d51 100644 --- a/docs/install.md +++ b/docs/install.md @@ -170,7 +170,7 @@ This should display the available subcommands: `task`, `merge`, `list`, `cleanup ### Step 5: Confirm with user -Tell the user installation is complete. Show them a quick usage example: +Tell the user installation is complete. Mention the `ocwt` shortcut alias that was installed automatically: ```bash # Start an isolated agent session @@ -179,3 +179,8 @@ opencode-worktree task my-task-name # Start with an initial prompt opencode-worktree task my-task-name "Description of what to work on" ``` + +> **Tip:** The installer adds `ocwt` as a shell alias for `opencode-worktree` — use either interchangeably. If you installed manually or via `go install`, add it yourself: +> ```bash +> echo "alias ocwt='opencode-worktree'" >> ~/.zshrc # or ~/.bashrc +> ``` diff --git a/install.sh b/install.sh index da1a623..9b6e130 100755 --- a/install.sh +++ b/install.sh @@ -109,4 +109,45 @@ complete -F _opencode_worktree opencode-worktree' printf 'Restart your shell or run: source %s\n' "$rc_file" } +install_alias() { + alias_marker="# opencode-worktree alias" + alias_line="alias ocwt='opencode-worktree'" + snippet="$alias_marker +$alias_line" + + shell="$(basename "${SHELL:-}")" + rc_file="" + + case "$shell" in + zsh) + if [ -f "$HOME/.zshrc" ]; then + rc_file="$HOME/.zshrc" + fi + ;; + bash) + if [ -f "$HOME/.bashrc" ]; then + rc_file="$HOME/.bashrc" + elif [ -f "$HOME/.bash_profile" ]; then + rc_file="$HOME/.bash_profile" + fi + ;; + esac + + if [ -z "$rc_file" ]; then + printf '\nShortcut: you can add this alias to your shell profile:\n' + printf ' %s\n' "$alias_line" + return + fi + + if grep -qF "$alias_marker" "$rc_file" 2>/dev/null; then + printf '\nShell alias (ocwt) already installed in %s\n' "$rc_file" + return + fi + + printf '\n%s\n' "$snippet" >> "$rc_file" + printf '\nShell alias installed: ocwt → opencode-worktree\n' + printf 'Restart your shell or run: source %s\n' "$rc_file" +} + install_completions +install_alias