feat(bash): move completions to separate file

This commit is contained in:
ange 2024-06-23 18:43:35 +02:00
parent 7ae0b331cf
commit f2464c73f7
Signed by: ange
GPG Key ID: 9E0C4157BB7BEB1D
4 changed files with 31 additions and 30 deletions

View File

@ -2,8 +2,6 @@
set -o vi set -o vi
shopt -s autocd progcomp_alias
FZF_ALT_C_OPTS=--walker=dir,follow FZF_ALT_C_OPTS=--walker=dir,follow
. /usr/share/fzf/key-bindings.bash . /usr/share/fzf/key-bindings.bash
@ -11,9 +9,3 @@ for f in "$HOME/.config/bash/"*.bash; do
# shellcheck disable=SC1090 # shellcheck disable=SC1090
. "$f" . "$f"
done done
complete -r -D
for f in kill kubectl git; do
# shellcheck disable=SC1090
. "/usr/share/bash-completion/completions/$f"
done

View File

@ -0,0 +1,30 @@
shopt -s progcomp_alias
complete -r -D
for f in kill kubectl git pacman ssh xrandr; do
# shellcheck disable=SC1090
. "/usr/share/bash-completion/completions/$f"
done
complete -F _pacman pac
function _kns() {
mapfile -t COMPREPLY < <(compgen -W \
"$(kubectl get namespace -o jsonpath='{..metadata.name}')" \
-- "${COMP_WORDS[1]}")
}
complete -F _kns kns
function _kctx() {
mapfile -t COMPREPLY < <(compgen -W \
"$(kubectl config get-contexts -o name)" \
-- "${COMP_WORDS[1]}")
}
complete -F _kctx kctx
function _gi() {
mapfile -t COMPREPLY < <(compgen -W \
"$(curl -sfL https://www.toptal.com/developers/gitignore/api/list | tr ',' '\n')" \
-- "${COMP_WORDS[1]}")
}
complete -F _gi gi

View File

@ -4,13 +4,6 @@ function gi() {
curl -fL "https://www.toptal.com/developers/gitignore/api/$*" curl -fL "https://www.toptal.com/developers/gitignore/api/$*"
} }
function _gi() {
mapfile -t COMPREPLY < <(compgen -W \
"$(curl -sfL https://www.toptal.com/developers/gitignore/api/list | tr ',' '\n')" \
-- "${COMP_WORDS[1]}")
}
complete -F _gi gi
alias g='git' \ alias g='git' \
ga='git add' \ ga='git add' \
gaa='git add --all' \ gaa='git add --all' \
@ -29,6 +22,7 @@ alias g='git' \
gl='git pull' \ gl='git pull' \
glo='git log --oneline --decorate' \ glo='git log --oneline --decorate' \
gmr='git merge' \ gmr='git merge' \
gp='git push' \
gr='git remote' \ gr='git remote' \
grb='git rebase' \ grb='git rebase' \
grev='git revert' \ grev='git revert' \

View File

@ -18,13 +18,6 @@ function kns() {
tee "$cache" <<< "$1" tee "$cache" <<< "$1"
} }
function _kns() {
mapfile -t COMPREPLY < <(compgen -W \
"$(kubectl get namespace -o jsonpath='{..metadata.name}')" \
-- "${COMP_WORDS[1]}")
}
complete -F _kns kns
function kctx() { function kctx() {
local cache="$HOME/.local/state/${FUNCNAME[0]}" local cache="$HOME/.local/state/${FUNCNAME[0]}"
@ -41,14 +34,6 @@ function kctx() {
tee "$cache" <<< "$1" tee "$cache" <<< "$1"
} }
function _kctx() {
mapfile -t COMPREPLY < <(compgen -W \
"$(kubectl config get-contexts -o name)" \
-- "${COMP_WORDS[1]}")
}
complete -F _kctx kctx
alias kga='kubectl get "$(kubectl api-resources --verbs=list --namespaced -oname | grep -v event | paste -sd,)"' alias kga='kubectl get "$(kubectl api-resources --verbs=list --namespaced -oname | grep -v event | paste -sd,)"'
alias k=kubectl \ alias k=kubectl \