From d6cdbe44c4aa8145222c9636a219a70294a44fdc Mon Sep 17 00:00:00 2001 From: AmirHossein Sakhravi Date: Mon, 3 Nov 2025 17:59:07 +0330 Subject: [PATCH] fix(cli): use the globally installed version for shell script generation (#84) * global install tab * readme * changeset --- .changeset/lemon-crabs-bathe.md | 5 +++++ README.md | 22 ++++++++++++++++++++++ bin/cli.ts | 10 +++++++--- 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 .changeset/lemon-crabs-bathe.md 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); } -- 2.51.2