diff --git a/dotfiles/.local/share/bash-completion/completions/hyperfine.bash b/dotfiles/.local/share/bash-completion/completions/hyperfine.bash new file mode 100644 index 00000000..ce61b4ed --- /dev/null +++ b/dotfiles/.local/share/bash-completion/completions/hyperfine.bash @@ -0,0 +1,174 @@ +_hyperfine() { + local i cur prev opts cmds + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + cmd="" + opts="" + + for i in ${COMP_WORDS[@]} + do + case "${i}" in + "$1") + cmd="hyperfine" + ;; + *) + ;; + esac + done + + case "${cmd}" in + hyperfine) + opts="-h -V -w -m -M -r -s -p -c -P -D -L -S -N -i -u -n --help --version --warmup --min-runs --max-runs --runs --setup --prepare --cleanup --parameter-scan --parameter-step-size --parameter-list --style --shell --ignore-failure --time-unit --export-asciidoc --export-csv --export-json --export-markdown --export-orgmode --show-output --output --command-name --min-benchmarking-time --debug-mode ..." + if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + --warmup) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -w) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --min-runs) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -m) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --max-runs) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -M) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --runs) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -r) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --setup) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -s) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --prepare) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -p) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --cleanup) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -c) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --parameter-scan) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -P) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --parameter-step-size) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -D) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --parameter-list) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -L) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --style) + COMPREPLY=($(compgen -W "auto basic full nocolor color none" -- "${cur}")) + return 0 + ;; + --shell) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -S) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --time-unit) + COMPREPLY=($(compgen -W "millisecond second" -- "${cur}")) + return 0 + ;; + -u) + COMPREPLY=($(compgen -W "millisecond second" -- "${cur}")) + return 0 + ;; + --export-asciidoc) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --export-csv) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --export-json) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --export-markdown) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --export-orgmode) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --output) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --command-name) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -n) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --min-benchmarking-time) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + esac +} + +complete -F _hyperfine -o bashdefault -o default hyperfine diff --git a/dotfiles/.local/share/bash-completion/generate.sh b/dotfiles/.local/share/bash-completion/generate.sh index da4ecdf7..f4dff997 100644 --- a/dotfiles/.local/share/bash-completion/generate.sh +++ b/dotfiles/.local/share/bash-completion/generate.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +### Initialize +mkdir -p "$HOME/.local/share/bash-completion/completions" + ### Deno if command -v deno > /dev/null; then deno completions bash > "$HOME/.local/share/bash-completion/completions/deno.bash" @@ -53,8 +56,10 @@ if command -v helm > /dev/null; then fi ### Hyperfine -if command -v hyperfine > /dev/null && [ -f /usr/local/src/hyperfine/autocomplete/hyperfine.bash-completion ]; then - cp /usr/local/src/hyperfine/autocomplete/hyperfine.bash-completion "$HOME/.local/share/bash-completion/completions/hyperfine.bash" +if command -v hyperfine > /dev/null && command -v brew > /dev/null && [ -f "$(brew --prefix hyperfine)/etc/bash_completion.d/hyperfine.bash" ]; then + cp "$(brew --prefix hyperfine)/etc/bash_completion.d/hyperfine.bash" "$HOME/.local/share/bash-completion/completions/hyperfine.bash" +elif command -v hyperfine > /dev/null; then + fi ### kubectl