gwqadd 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/bin/gwqadd.mjs +8 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -45,15 +45,19 @@ Then add the shell integration:
|
|
|
45
45
|
|
|
46
46
|
```sh
|
|
47
47
|
# zsh — ~/.zshrc
|
|
48
|
-
eval "$(gwqadd --init zsh)"
|
|
48
|
+
eval "$(command gwqadd --init zsh)"
|
|
49
49
|
|
|
50
50
|
# bash — ~/.bashrc
|
|
51
|
-
eval "$(gwqadd --init bash)"
|
|
51
|
+
eval "$(command gwqadd --init bash)"
|
|
52
52
|
|
|
53
53
|
# fish — ~/.config/fish/config.fish
|
|
54
|
-
gwqadd --init fish | source
|
|
54
|
+
command gwqadd --init fish | source
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
+
`command` matters: each tool defines a shell function with its own name, so on a
|
|
58
|
+
second `source ~/.zshrc` the *function* would answer, capture the `--init` output
|
|
59
|
+
and try to `cd` into it. `command` skips functions and goes to the binary.
|
|
60
|
+
|
|
57
61
|
Reload the shell and `gwqadd` moves it.
|
|
58
62
|
|
|
59
63
|
Prefer a different name? `eval "$(gwqadd --init zsh --cmd gwa)"` gives you `gwa`.
|
package/bin/gwqadd.mjs
CHANGED
|
@@ -25,7 +25,7 @@ const HELP = `${PKG} ${VERSION} — create a branch and its gwq worktree here, a
|
|
|
25
25
|
|
|
26
26
|
USAGE
|
|
27
27
|
${PKG} [options] [<branch>]
|
|
28
|
-
eval "$(${PKG} --init zsh)"
|
|
28
|
+
eval "$(command ${PKG} --init zsh)" # then \`${PKG}\` moves the shell itself
|
|
29
29
|
|
|
30
30
|
OPTIONS
|
|
31
31
|
--init <shell> print shell integration for zsh | bash | fish, then exit
|
|
@@ -247,7 +247,7 @@ function shellInit(shell, fnName) {
|
|
|
247
247
|
|
|
248
248
|
if (shell === 'zsh') {
|
|
249
249
|
return `# ${PKG} ${VERSION} — zsh integration
|
|
250
|
-
# Add to ~/.zshrc: eval "$(${PKG} --init zsh)"
|
|
250
|
+
# Add to ~/.zshrc: eval "$(command ${PKG} --init zsh)"
|
|
251
251
|
|
|
252
252
|
__${slug}_fallback=${shq(SELF)}
|
|
253
253
|
|
|
@@ -290,7 +290,7 @@ ${fnName}() {
|
|
|
290
290
|
|
|
291
291
|
if (shell === 'bash') {
|
|
292
292
|
return `# ${PKG} ${VERSION} — bash integration
|
|
293
|
-
# Add to ~/.bashrc: eval "$(${PKG} --init bash)"
|
|
293
|
+
# Add to ~/.bashrc: eval "$(command ${PKG} --init bash)"
|
|
294
294
|
|
|
295
295
|
__${slug}_fallback=${shq(SELF)}
|
|
296
296
|
|
|
@@ -330,7 +330,7 @@ ${fnName}() {
|
|
|
330
330
|
|
|
331
331
|
if (shell === 'fish') {
|
|
332
332
|
return `# ${PKG} ${VERSION} — fish integration
|
|
333
|
-
# Add to ~/.config/fish/config.fish: ${PKG} --init fish | source
|
|
333
|
+
# Add to ~/.config/fish/config.fish: command ${PKG} --init fish | source
|
|
334
334
|
|
|
335
335
|
set -g __${slug}_fallback ${fishq(SELF)}
|
|
336
336
|
|
|
@@ -479,8 +479,6 @@ process.on('uncaughtException', (err) => {
|
|
|
479
479
|
});
|
|
480
480
|
|
|
481
481
|
async function waitForKey() {
|
|
482
|
-
process.stdin.removeAllListeners('data');
|
|
483
|
-
process.stdin.removeAllListeners('keypress');
|
|
484
482
|
try {
|
|
485
483
|
process.stdin.setRawMode(true);
|
|
486
484
|
rawModeEngaged = true;
|
|
@@ -519,6 +517,9 @@ async function askLine(question, initial = '') {
|
|
|
519
517
|
const answer = rl.question(question);
|
|
520
518
|
if (initial) rl.write(initial);
|
|
521
519
|
return (await answer).trim();
|
|
520
|
+
} catch (err) {
|
|
521
|
+
if (err?.code === 'ABORT_ERR') die('E_INTERRUPTED', 'cancelled');
|
|
522
|
+
throw err;
|
|
522
523
|
} finally {
|
|
523
524
|
rl.close();
|
|
524
525
|
}
|
|
@@ -1202,7 +1203,7 @@ async function finish({ repo, branch, base, path, created }) {
|
|
|
1202
1203
|
stderr.write('\n');
|
|
1203
1204
|
stderr.write(renderBox(cdCommand) + '\n');
|
|
1204
1205
|
stderr.write(
|
|
1205
|
-
` ${dim('tip:')} ${dim(`eval "$(${PKG} --init zsh)"`)} ${dim('lets')} ` +
|
|
1206
|
+
` ${dim('tip:')} ${dim(`eval "$(command ${PKG} --init zsh)"`)} ${dim('lets')} ` +
|
|
1206
1207
|
`${bold(PKG)} ${dim('cd for you')}\n`,
|
|
1207
1208
|
);
|
|
1208
1209
|
|