Skip to content

Commit d6cdbe4

Browse files
authored
fix(cli): use the globally installed version for shell script generation (#84)
* global install tab * readme * changeset
1 parent 5d9340d commit d6cdbe4

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

.changeset/lemon-crabs-bathe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@bomb.sh/tab': patch
3+
---
4+
5+
fix(cli): use the globally installed version for shell completions

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,28 @@ tab solves this complexity by providing autocompletions that work consistently a
1414

1515
## Installation
1616

17+
### For Package Manager Completions (Global install is recommended)
18+
19+
```bash
20+
npm install -g @bomb.sh/tab
21+
```
22+
23+
Then enable completions permanently:
24+
25+
```bash
26+
# For zsh
27+
echo 'source <(tab pnpm zsh)' >> ~/.zshrc
28+
source ~/.zshrc
29+
30+
# For bash
31+
echo 'source <(tab pnpm bash)' >> ~/.bashrc
32+
source ~/.bashrc
33+
34+
# The same can be done for other shells!
35+
```
36+
37+
### For CLI Library (Adding Completions to Your CLI)
38+
1739
```bash
1840
npm install @bomb.sh/tab
1941
# or

bin/cli.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ async function main() {
6464

6565
function generateCompletionScript(packageManager: string, shell: string) {
6666
const name = packageManager;
67-
const executable = process.env.npm_config_user_agent
68-
? `npx --yes @bomb.sh/tab ${packageManager}`
69-
: `node ${process.argv[1]} ${packageManager}`;
67+
68+
const isLocalDev = process.argv[1].endsWith('dist/bin/cli.js');
69+
70+
const executable = isLocalDev
71+
? `node ${process.argv[1]} ${packageManager}`
72+
: `tab ${packageManager}`;
73+
7074
script(shell as any, name, executable);
7175
}
7276

0 commit comments

Comments
 (0)