Last active
January 30, 2025 06:55
-
-
Save mangs/0580f8f6628b7d4518cd2b667e132e15 to your computer and use it in GitHub Desktop.
Bun Bash Completions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
_bun_completions() { | |
COMP_WORDBREAKS=${COMP_WORDBREAKS//:} | |
COMPREPLY=() | |
local cur="${COMP_WORDS[COMP_CWORD]}" | |
local prev="${COMP_WORDS[COMP_CWORD-1]}" | |
# local all=$(bun getcompletes) | |
# local binaries=$(bun getcompletes b) | |
local scripts=$(bun getcompletes s) | |
# local commands=$(echo "${all[@]}" "${binaries[@]}" "${scripts[@]}" | tr ' ' '\n' | sort | uniq -u) # Missing commands so using a hard-coded list for now | |
local commands="add build create exec init install link outdated patch pm publish remove repl run test unlink update upgrade x" | |
case "${prev}" in | |
bun) | |
COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) ) | |
return 0 | |
;; | |
run) | |
COMPREPLY=( $(compgen -W "${scripts}" -- ${cur}) ) | |
return 0 | |
;; | |
esac | |
} | |
complete -F _bun_completions bun |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment