2022-10-29 04:35:57 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2022-11-22 05:12:56 -08:00
|
|
|
### Initialize
|
2022-11-22 06:01:44 -08:00
|
|
|
COMPLETION_DIR="$HOME/.local/share/bash-completion/completions"
|
2022-11-22 05:40:52 -08:00
|
|
|
mkdir -p "$COMPLETION_DIR"
|
|
|
|
FALLBACK_URL="https://gitlab.com/megabyte-labs/misc/dotfiles/-/raw/master/dotfiles/.local/share/bash-completion/completions"
|
2022-11-22 05:12:56 -08:00
|
|
|
|
2022-10-29 07:08:44 -07:00
|
|
|
### Deno
|
|
|
|
if command -v deno > /dev/null; then
|
2022-11-22 05:40:52 -08:00
|
|
|
deno completions bash > "$COMPLETION_DIR/deno.bash"
|
|
|
|
elif [ -f "$COMPLETION_DIR/deno.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/deno.bash"
|
2022-10-29 07:08:44 -07:00
|
|
|
fi
|
|
|
|
|
2022-10-29 04:35:57 -07:00
|
|
|
### direnv
|
|
|
|
if command -v direnv > /dev/null; then
|
2022-11-22 05:40:52 -08:00
|
|
|
direnv hook bash > "$COMPLETION_DIR/direnv.bash"
|
|
|
|
elif [ -f "$COMPLETION_DIR/direnv.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/direnv.bash"
|
2022-10-29 04:35:57 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
### fd
|
2022-11-22 05:40:52 -08:00
|
|
|
if command -v fd > /dev/null && command -v brew > /dev/null && [ -f "$(brew --prefix fd)/etc/bash_completion.d/fd" ]; then
|
|
|
|
cp "$(brew --prefix fd)/etc/bash_completion.d/fd" "$COMPLETION_DIR/fd.bash"
|
|
|
|
elif command -v fd > /dev/null; then
|
|
|
|
curl -sSL "$FALLBACK_URL/fd.bash" > "$COMPLETION_DIR/fd.bash"
|
|
|
|
elif [ -f "$COMPLETION_DIR/fd.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/fd.bash"
|
2022-10-29 04:35:57 -07:00
|
|
|
fi
|
|
|
|
|
2022-10-29 07:40:02 -07:00
|
|
|
### fig
|
|
|
|
if command -v fig > /dev/null; then
|
2022-11-22 05:40:52 -08:00
|
|
|
fig completion bash > "$COMPLETION_DIR/fig.bash"
|
|
|
|
elif [ -f "$COMPLETION_DIR/fig.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/fig.bash"
|
2022-10-29 07:40:02 -07:00
|
|
|
fi
|
|
|
|
|
2022-11-22 06:01:44 -08:00
|
|
|
### fzf
|
|
|
|
if command -v fzf > /dev/null && command -v brew > /dev/null && [ -f "$(brew --prefix fzf)/shell/completion.bash" ]; then
|
|
|
|
cp "$(brew --prefix fzf)/shell/completion.bash" "$COMPLETION_DIR/fzf.bash"
|
|
|
|
cp "$(brew --prefix fzf)/shell/key-bindings.bash" "$COMPLETION_DIR/fzf-key-bindings.bash"
|
|
|
|
elif command -v fzf > /dev/null; then
|
|
|
|
curl -sSL "$FALLBACK_URL/fzf.bash" > "$COMPLETION_DIR/fzf.bash"
|
|
|
|
curl -sSL "$FALLBACK_URL/fzf-key-bindings.bash" > "$COMPLETION_DIR/fzf-key-bindings.bash"
|
|
|
|
elif [ -f "$COMPLETION_DIR/fzf.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/fzf.bash"
|
|
|
|
rm "$COMPLETION_DIR/fzf-key-bindings.bash"
|
|
|
|
fi
|
|
|
|
|
2022-10-29 07:33:46 -07:00
|
|
|
### gh
|
|
|
|
if command -v gh > /dev/null; then
|
2022-11-22 05:40:52 -08:00
|
|
|
gh completion -s bash > "$COMPLETION_DIR/gh.bash"
|
|
|
|
elif [ -f "$COMPLETION_DIR/gh.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/gh.bash"
|
2022-10-29 07:33:46 -07:00
|
|
|
fi
|
|
|
|
|
2022-10-29 04:35:57 -07:00
|
|
|
### Google Cloud SDK
|
2022-11-22 06:01:44 -08:00
|
|
|
if command -v gcloud > /dev/null; then
|
|
|
|
curl -sSL "$FALLBACK_URL/gcloud.bash" > "COMPLETION_DIR/gcloud.bash"
|
|
|
|
elif [ -f "$COMPLETION_DIR/gcloud.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/gcloud.bash"
|
2022-10-29 04:35:57 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
### Googler
|
2022-11-22 05:40:52 -08:00
|
|
|
if command -v googler > /dev/null && command -v brew > /dev/null && [ -f "$(brew --prefix googler)/etc/bash_completion.d/googler-completion.bash" ]; then
|
|
|
|
cp "$(brew --prefix googler)/etc/bash_completion.d/googler-completion.bash" "$COMPLETION_DIR/googler.bash"
|
|
|
|
elif command -v googler > /dev/null; then
|
|
|
|
curl -sSL "$FALLBACK_URL/googler.bash" > "$COMPLETION_DIR/googler.bash"
|
|
|
|
elif [ -f "$COMPLETION_DIR/googler.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/googler.bash"
|
2022-10-29 04:35:57 -07:00
|
|
|
fi
|
|
|
|
|
2022-11-20 20:22:46 -08:00
|
|
|
### Gradle
|
|
|
|
if command -v gradle > /dev/null; then
|
2022-11-22 05:40:52 -08:00
|
|
|
curl -sSL https://raw.githubusercontent.com/eriwen/gradle-completion/master/gradle-completion.bash > "$COMPLETION_DIR/gradle.bash"
|
2022-11-22 06:01:44 -08:00
|
|
|
elif [ -f "$COMPLETION_DIR/gradle.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/gradle.bash"
|
2022-11-20 20:22:46 -08:00
|
|
|
fi
|
|
|
|
|
2022-10-29 07:08:44 -07:00
|
|
|
### Helm
|
|
|
|
if command -v helm > /dev/null; then
|
2022-11-22 05:40:52 -08:00
|
|
|
helm completion bash > "$COMPLETION_DIR/helm.bash"
|
2022-11-22 06:01:44 -08:00
|
|
|
elif [ -f "$COMPLETION_DIR/helm.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/helm.bash"
|
2022-10-29 07:08:44 -07:00
|
|
|
fi
|
|
|
|
|
2022-10-29 04:35:57 -07:00
|
|
|
### Hyperfine
|
2022-11-22 05:12:56 -08:00
|
|
|
if command -v hyperfine > /dev/null && command -v brew > /dev/null && [ -f "$(brew --prefix hyperfine)/etc/bash_completion.d/hyperfine.bash" ]; then
|
2022-11-22 05:40:52 -08:00
|
|
|
cp "$(brew --prefix hyperfine)/etc/bash_completion.d/hyperfine.bash" "$COMPLETION_DIR/hyperfine.bash"
|
2022-11-22 05:12:56 -08:00
|
|
|
elif command -v hyperfine > /dev/null; then
|
2022-11-22 06:01:44 -08:00
|
|
|
curl -sSL "$FALLBACK_URL/hyperfine.bash" > "$COMPLETION_DIR/hyperfine.bash"
|
|
|
|
elif [ -f "$COMPLETION_DIR/hyperfine.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/hyperfine.bash"
|
2022-10-29 04:35:57 -07:00
|
|
|
fi
|
|
|
|
|
2022-10-29 07:33:46 -07:00
|
|
|
### kubectl
|
|
|
|
if command -v kubectl > /dev/null; then
|
2022-11-22 05:40:52 -08:00
|
|
|
kubectl completion bash > "$COMPLETION_DIR/kubectl.bash"
|
2022-11-22 06:01:44 -08:00
|
|
|
elif [ -f "$COMPLETION_DIR/kubectl.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/kubectl.bash"
|
2022-10-29 07:33:46 -07:00
|
|
|
fi
|
|
|
|
|
2022-10-29 04:35:57 -07:00
|
|
|
### mcfly
|
|
|
|
export MCFLY_KEY_SCHEME=vim
|
|
|
|
if command -v mcfly > /dev/null; then
|
2022-11-22 05:40:52 -08:00
|
|
|
mcfly init bash > "$COMPLETION_DIR/mcfly.bash"
|
2022-11-22 06:01:44 -08:00
|
|
|
elif [ -f "$COMPLETION_DIR/mcfly.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/mcfly.bash"
|
|
|
|
fi
|
|
|
|
|
|
|
|
### nb
|
|
|
|
if command -v nb > /dev/null && command -v brew > /dev/null && [ -f "$(brew --prefix nb)/etc/bash_completion.d/nb.bash" ]; then
|
|
|
|
cp "$(brew --prefix nb)/etc/bash_completion.d/nb.bash" "$COMPLETION_DIR/nb.bash"
|
|
|
|
elif command -v nb > /dev/null; then
|
|
|
|
curl -sSL "$FALLBACK_URL/nb.bash" > "$COMPLETION_DIR/nb.bash"
|
|
|
|
elif [ -f "$COMPLETION_DIR/nb.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/nb.bash"
|
|
|
|
fi
|
|
|
|
|
|
|
|
### nnn
|
|
|
|
if command -v nnn > /dev/null && command -v brew > /dev/null && [ -f "$(brew --prefix nnn)/etc/bash_completion.d/nnn-completion.bash" ]; then
|
|
|
|
cp "$(brew --prefix nnn)/etc/bash_completion.d/nnn-completion.bash" "$COMPLETION_DIR/nnn.bash"
|
|
|
|
elif command -v nnn > /dev/null; then
|
|
|
|
curl -sSL "$FALLBACK_URL/nnn.bash" > "$COMPLETION_DIR/nnn.bash"
|
|
|
|
elif [ -f "$COMPLETION_DIR/nnn.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/nnn.bash"
|
2022-10-29 07:08:44 -07:00
|
|
|
fi
|
|
|
|
|
2022-11-21 06:09:37 -08:00
|
|
|
### npm
|
|
|
|
if command -v npm > /dev/null; then
|
2022-11-22 05:40:52 -08:00
|
|
|
npm completion > "$COMPLETION_DIR/npm.bash"
|
2022-11-22 06:01:44 -08:00
|
|
|
elif [ -f "$COMPLETION_DIR/npm.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/npm.bash"
|
2022-11-21 06:09:37 -08:00
|
|
|
fi
|
|
|
|
|
2022-10-29 07:08:44 -07:00
|
|
|
### Poetry
|
|
|
|
if command -v poetry > /dev/null; then
|
2022-11-22 05:40:52 -08:00
|
|
|
poetry completions bash > "$COMPLETION_DIR/poetry.bash"
|
2022-11-22 06:01:44 -08:00
|
|
|
elif [ -f "$COMPLETION_DIR/poetry.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/poetry.bash"
|
2022-10-29 07:08:44 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
### Volta
|
|
|
|
if command -v volta > /dev/null; then
|
2022-11-22 05:40:52 -08:00
|
|
|
volta completions bash > "$COMPLETION_DIR/volta.bash"
|
2022-11-22 06:01:44 -08:00
|
|
|
elif [ -f "$COMPLETION_DIR/volta.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/volta.bash"
|
2022-10-29 04:35:57 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
### wp-cli (only bash available)
|
2022-11-22 06:01:44 -08:00
|
|
|
if command -v wp > /dev/null; then
|
2022-11-22 05:40:52 -08:00
|
|
|
curl -sSL https://raw.githubusercontent.com/wp-cli/wp-cli/v2.7.1/utils/wp-completion.bash > "$COMPLETION_DIR/wp.bash"
|
2022-11-22 06:01:44 -08:00
|
|
|
elif [ -f "$COMPLETION_DIR/wp.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/wp.bash"
|
2022-10-29 04:35:57 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
### zoxide
|
|
|
|
if command -v zoxide >/dev/null; then
|
2022-11-22 05:40:52 -08:00
|
|
|
zoxide init bash > "$COMPLETION_DIR/zoxide.bash"
|
2022-11-22 06:01:44 -08:00
|
|
|
elif [ -f "$COMPLETION_DIR/zoxide.bash" ]; then
|
|
|
|
rm "$COMPLETION_DIR/zoxide.bash"
|
2022-10-29 04:35:57 -07:00
|
|
|
fi
|