diff --git a/.changeset/lemon-crabs-bathe.md b/.changeset/lemon-crabs-bathe.md new file mode 100644 index 0000000..d2acde3 --- /dev/null +++ b/.changeset/lemon-crabs-bathe.md @@ -0,0 +1,5 @@ +--- +'@bomb.sh/tab': patch +--- + +fix(cli): use the globally installed version for shell completions diff --git a/README.md b/README.md index 88a011e..28cccb1 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,28 @@ tab solves this complexity by providing autocompletions that work consistently a ## Installation +### For Package Manager Completions (Global install is recommended) + +```bash +npm install -g @bomb.sh/tab +``` + +Then enable completions permanently: + +```bash +# For zsh +echo 'source <(tab pnpm zsh)' >> ~/.zshrc +source ~/.zshrc + +# For bash +echo 'source <(tab pnpm bash)' >> ~/.bashrc +source ~/.bashrc + +# The same can be done for other shells! +``` + +### For CLI Library (Adding Completions to Your CLI) + ```bash npm install @bomb.sh/tab # or diff --git a/bin/cli.ts b/bin/cli.ts index 7b95012..b860f22 100644 --- a/bin/cli.ts +++ b/bin/cli.ts @@ -64,9 +64,13 @@ async function main() { function generateCompletionScript(packageManager: string, shell: string) { const name = packageManager; - const executable = process.env.npm_config_user_agent - ? `npx --yes @bomb.sh/tab ${packageManager}` - : `node ${process.argv[1]} ${packageManager}`; + + const isLocalDev = process.argv[1].endsWith('dist/bin/cli.js'); + + const executable = isLocalDev + ? `node ${process.argv[1]} ${packageManager}` + : `tab ${packageManager}`; + script(shell as any, name, executable); }