Skip to content

Commit 90a6039

Browse files
committed
Add pnpm completion
1 parent 07f708b commit 90a6039

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

system/.completion

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ if is-executable brew; then
66
. "$BREW_PREFIX/share/bash-completion/bash_completion"
77
fi
88

9-
# Dotfiles
9+
# dot
1010

1111
_dotfiles_completions() {
1212
local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -33,6 +33,32 @@ if is-executable git; then
3333
. "$BREW_PREFIX/etc/bash_completion.d/git-completion.bash"
3434
fi
3535

36-
# pnpm
36+
# pnpm (https://pnpm.io/completion)
3737

38-
[ -f ~/.config/tabtab/bash/__tabtab.bash ] && . $HOME/.config/tabtab/bash/__tabtab.bash || true
38+
_pnpm_completion () {
39+
local words cword
40+
if type _get_comp_words_by_ref &>/dev/null; then
41+
_get_comp_words_by_ref -n = -n @ -n : -w words -i cword
42+
else
43+
cword="$COMP_CWORD"
44+
words=("${COMP_WORDS[@]}")
45+
fi
46+
47+
local si="$IFS"
48+
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$cword" \
49+
COMP_LINE="$COMP_LINE" \
50+
COMP_POINT="$COMP_POINT" \
51+
SHELL=bash \
52+
pnpm completion-server -- "${words[@]}" \
53+
2>/dev/null)) || return $?
54+
IFS="$si"
55+
56+
if [ "$COMPREPLY" = "__tabtab_complete_files__" ]; then
57+
COMPREPLY=($(compgen -f -- "$cword"))
58+
fi
59+
60+
if type __ltrim_colon_completions &>/dev/null; then
61+
__ltrim_colon_completions "${words[cword]}"
62+
fi
63+
}
64+
complete -o default -F _pnpm_completion pnpm

0 commit comments

Comments
 (0)