improve bash completion performance
This commit is contained in:
parent
5b87003bf2
commit
5db4705aca
10 changed files with 26486 additions and 46 deletions
|
@ -2,46 +2,6 @@ if [ -f /usr/share/bash-completion/bash_completion ]; then
|
|||
source /usr/share/bash-completion/bash_completion
|
||||
fi
|
||||
|
||||
if type ykman > /dev/null 2>&1; then
|
||||
_ykman_completion() {
|
||||
local IFS=$'
|
||||
'
|
||||
COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \
|
||||
COMP_CWORD=$COMP_CWORD \
|
||||
_YKMAN_COMPLETE=complete $1 ) )
|
||||
return 0
|
||||
}
|
||||
|
||||
_ykman_completionetup() {
|
||||
local COMPLETION_OPTIONS=""
|
||||
local BASH_VERSION_ARR=(${BASH_VERSION//./ })
|
||||
# Only BASH version 4.4 and later have the nosort option.
|
||||
if [ ${BASH_VERSION_ARR[0]} -gt 4 ] || ([ ${BASH_VERSION_ARR[0]} -eq 4 ] && [ ${BASH_VERSION_ARR[1]} -ge 4 ]); then
|
||||
COMPLETION_OPTIONS="-o nosort"
|
||||
fi
|
||||
|
||||
complete $COMPLETION_OPTIONS -F _ykman_completion ykman
|
||||
}
|
||||
|
||||
_ykman_completionetup;
|
||||
fi
|
||||
|
||||
if type kubectl > /dev/null 2>&1; then
|
||||
source <(kubectl completion bash)
|
||||
fi
|
||||
|
||||
if type doctl > /dev/null 2>&1; then
|
||||
source <(doctl completion bash)
|
||||
fi
|
||||
|
||||
if type helm > /dev/null 2>&1; then
|
||||
source <(helm completion bash)
|
||||
fi
|
||||
|
||||
if type mc > /dev/null 2>&1; then
|
||||
complete -C mc mc
|
||||
fi
|
||||
|
||||
# Homebrew completions
|
||||
if command -v brew > /dev/null; then
|
||||
HOMEBREW_PREFIX=$(brew --prefix)
|
||||
|
@ -55,12 +15,28 @@ if command -v brew > /dev/null; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# Docker completions
|
||||
for COMPLETION in /Applications/Docker.app/Contents/Resources/etc/*.bash-completion; do
|
||||
[ -f ${COMPLETION} ] && source ${COMPLETION}
|
||||
done
|
||||
|
||||
# Add completion to aliases
|
||||
# See: https://github.com/cykerway/complete-alias
|
||||
source ~/.homesick/repos/complete-alias/complete_alias
|
||||
complete -F _complete_alias "${!BASH_ALIASES[@]}"
|
||||
if type brew > /dev/null 2>&1; then
|
||||
HOMEBREW_PREFIX=$(brew --prefix)
|
||||
for COMPLETION in "$HOMEBREW_PREFIX"/etc/bash_completion.d/*; do
|
||||
[[ -f $COMPLETION ]] && source "$COMPLETION"
|
||||
done
|
||||
if [[ -f ${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh ]]; then
|
||||
source "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Update complations if old
|
||||
MAX_AGE=$(( 3 * 24 * 60 )) # Minutes
|
||||
if (( $(find "${HOME}/.bash_completion.d/generated" -mmin +${MAX_AGE} | wc -l) > 0 )) || [ -n "${UPDATE_COMPLETIONS}" ]; then
|
||||
echo "Start update of completions"
|
||||
. ~/.homesick/repos/dotfiles/update-completions.sh
|
||||
echo "Completions updated"
|
||||
fi
|
||||
|
||||
for F in ~/.bash_completion.d/*; do
|
||||
source $F
|
||||
done
|
||||
|
|
1
home/.bash_completion.d/complete-alias
Symbolic link
1
home/.bash_completion.d/complete-alias
Symbolic link
|
@ -0,0 +1 @@
|
|||
/Users/stv0g_local/.homesick/repos/complete-alias/bash_completion.sh
|
3
home/.bash_completion.d/docker
Normal file
3
home/.bash_completion.d/docker
Normal file
|
@ -0,0 +1,3 @@
|
|||
for COMPLETION in /Applications/Docker.app/Contents/Resources/etc/*.bash-completion; do
|
||||
[ -f ${COMPLETION} ] && source ${COMPLETION}
|
||||
done
|
26407
home/.bash_completion.d/generated
Normal file
26407
home/.bash_completion.d/generated
Normal file
File diff suppressed because it is too large
Load diff
1
home/.bash_completion.d/homeshick
Symbolic link
1
home/.bash_completion.d/homeshick
Symbolic link
|
@ -0,0 +1 @@
|
|||
/Users/stv0g_local/.homesick/repos/homeshick/completions/homeshick-completion.bash
|
3
home/.bash_completion.d/mc
Normal file
3
home/.bash_completion.d/mc
Normal file
|
@ -0,0 +1,3 @@
|
|||
if type mc > /dev/null 2>&1; then
|
||||
complete -C mc mc
|
||||
fi
|
23
home/.bash_completion.d/ykman
Normal file
23
home/.bash_completion.d/ykman
Normal file
|
@ -0,0 +1,23 @@
|
|||
if type ykman > /dev/null 2>&1; then
|
||||
_ykman_completion() {
|
||||
local IFS=$'
|
||||
'
|
||||
COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \
|
||||
COMP_CWORD=$COMP_CWORD \
|
||||
_YKMAN_COMPLETE=complete $1 ) )
|
||||
return 0
|
||||
}
|
||||
|
||||
_ykman_completionetup() {
|
||||
local COMPLETION_OPTIONS=""
|
||||
local BASH_VERSION_ARR=(${BASH_VERSION//./ })
|
||||
# Only BASH version 4.4 and later have the nosort option.
|
||||
if [ ${BASH_VERSION_ARR[0]} -gt 4 ] || ([ ${BASH_VERSION_ARR[0]} -eq 4 ] && [ ${BASH_VERSION_ARR[1]} -ge 4 ]); then
|
||||
COMPLETION_OPTIONS="-o nosort"
|
||||
fi
|
||||
|
||||
complete $COMPLETION_OPTIONS -F _ykman_completion ykman
|
||||
}
|
||||
|
||||
_ykman_completionetup;
|
||||
fi
|
|
@ -20,12 +20,13 @@ HISTCONTROL=ignorespace:ignoredups:erasedups
|
|||
HISTSIZE=99999999
|
||||
HISTFILESIZE=99999999
|
||||
|
||||
HOSTFILE=$HOME/.hosts
|
||||
|
||||
# make less more friendly for non-text input files, see lesspipe(1)
|
||||
if [ -x /usr/bin/lesspipe ]; then eval "$(lesspipe)"; fi
|
||||
|
||||
# Homeshick
|
||||
source ~/.homesick/repos/homeshick/homeshick.sh
|
||||
source ~/.homesick/repos/homeshick/completions/homeshick-completion.bash
|
||||
|
||||
# enable color support of ls and also add handy aliases
|
||||
if hash dircolors 2>/dev/null; then
|
||||
|
|
25
update-completions.sh
Normal file
25
update-completions.sh
Normal file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Update hostlist
|
||||
. ~/workspace/snippets/bash/recursive-axfr.sh 0l.de > ~/.hosts.nulll
|
||||
. ~/workspace/snippets/bash/recursive-axfr.sh k8s.0l.de @kube-dns.kube-system.svc.k8s.0l.de. > ~/.hosts.k8s
|
||||
|
||||
echo '$include /etc/hosts.k8s' > ~/.hosts
|
||||
echo '$include /etc/hosts.nulll' >> ~/.hosts
|
||||
echo '$include /etc/hosts' >> ~/.hosts
|
||||
|
||||
# Update slow completions
|
||||
COMPLETIONS_GENERATED="/Users/stv0g_local/.bash_completion.d/generated"
|
||||
|
||||
rm ${COMPLETIONS_GENERATED}
|
||||
if type kubectl > /dev/null 2>&1; then
|
||||
kubectl completion bash >> ${COMPLETIONS_GENERATED}
|
||||
fi
|
||||
|
||||
if type doctl > /dev/null 2>&1; then
|
||||
doctl completion bash >> ${COMPLETIONS_GENERATED}
|
||||
fi
|
||||
|
||||
if type helm > /dev/null 2>&1; then
|
||||
helm completion bash >> ${COMPLETIONS_GENERATED}
|
||||
fi
|
Loading…
Add table
Reference in a new issue