New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should not modify user shell dotfiles #3083
Comments
Seconded! It's intrusive and kind of annoying for a program to modify my
Part of the problem seems to be that this behavior is inherent to tabtab, which is what pnpm uses to provide shell completions: tabtab only exposes API to imperatively install scripts into hardcoded locations but not to, say, print the scripts to stdout. This sort of intrusive behavior has spawned several problems: |
I’ve done something hacky (in zsh)… #!/usr/bin/env zsh
function get_completion_script() {
export HOME=$(mktemp -d "${TMPDIR:-/tmp}/fool-tabtab-mwahaha.XXXXX")
pnpm install-completion zsh | head -n3 | sed 's/Added/Failed to add/' >&2
sed -n 's/^ //p' "$HOME/.config/tabtab/zsh/pnpm.zsh"
}
get_completion_script This fakes the home directory, passes improved output of I found I needed to strip the Also don’t be like me; force zsh to re-cache completions…
Edit: Try this, too; I found the first version flaky. #!/usr/bin/env zsh
function get_completion_script() {
export HOME=$(mktemp -d "${TMPDIR:-/tmp}/fool-tabtab-mwahaha.XXXXX")
pnpm install-completion zsh | head -n3 | sed 's/Added/Failed to add/' >&2
echo -e "#compdef pnpm\n"
sed -n 's/^ //p' "$HOME/.config/tabtab/zsh/pnpm.zsh"
}
get_completion_script |
Agreed. It does the same with |
I don't have objections to change how this command works. I was using tabtab as a point of reference but if other tools work differently, I am totally fine to follow best practices. |
Standard behavior:
|
I will create a PR that add a command called |
* feat(completion): generate-completion close #3083 * feat: better error message * test: generate-completion * feat(completion): add powershell * chore(deps): update @pnpm/tabtab to 0.3.0 * switch to provided type declarations * fix typings * update tests * update bundle scripts * refactor: remove unnecessary `??` * refactor: replace a type def with provided types * chore(deps): update @pnpm/tabtab to 0.4.0 * feat(cli): rename completion command * chore(deps): update @pnpm/tabtab to 0.4.1 * refactor: use tabtab's new features * fix: pass shell * chore(deps): update @pnpm/tabtab to 0.5.0 * chore(deps): update @pnpm/tabtab to 0.5.1 * fix: remove unused import * refactor: move completion to plugins * feat: remove `{install,uninstall}-completion` Just `pnpm completion` is enough * test: fix * refactor: direct import * refactor: move tests to next to the lib * refactor: merge 2 packages into 1 * fix: update changeset and remove install-completion
pnpm version: 5.15
Code to reproduce the issue:
Run
pnpm install-completion zsh
Expected behavior:
I get a snippet to add to
.zshrc
or equivalent init file (kubectl completion zsh
andhelm completion zsh
do this)Actual behavior:
pnpm creates/updates
.zshrc
this has no effect on my system,
.zshrc
is located elsewhere for.. reasonsAdditional information:
node -v
prints: v12.18.4The text was updated successfully, but these errors were encountered: