# chezmoi:template:left-delimiter=#{{
#{{- /* vim: set filetype=bash: */ -}}

#{{ if stat "/etc/bash_completion" -}}
source /etc/bash_completion
#{{ end -}}

#{{ if stat "/usr/local/etc/bash_completion" -}}
source /usr/local/etc/bash_completion
#{{ end -}}

#{{ if stat "/usr/local/etc/bash_completion.d/" -}}
for i in $(ls /usr/local/etc/bash_completion.d/); do
    if [ -r "/usr/local/etc/bash_completion.d/$i" ]; then
        # shellcheck disable=SC1090
        source "/usr/local/etc/bash_completion.d/$i"
    fi
done
unset i
#{{ end -}}

#{{ if lookPath "brew" -}}
if [ -f "$(brew --prefix)/share/bash-completion/bash_completion" ]; then
    source "$(brew --prefix)/share/bash-completion/bash_completion"
fi
#{{ end -}}

#{{ if lookPath "helm" -}}
source <(helm completion bash)
#{{ end -}}

#{{ if lookPath "kubectl" -}}
source <(kubectl completion bash)
#{{ end -}}

#{{ if lookPath "starship" -}}
source <(starship init bash)
#{{ end -}}

#{{ if lookPath "direnv" -}}
source <(direnv hook bash)
#{{ end -}}

#{{ if lookPath "erd" -}}
# comment out due to error with erd version 3.1.0
#eval "$(erd --completions bash)"
#{{ end -}}

#{{ if lookPath "trubka" -}}
source <(trubka --completion-script-bash)
#{{ end -}}

#{{ if lookPath "rbenv" -}}
source <(rbenv init -)
#{{ end -}}

#{{ if stat (joinPath .chezmoi.homeDir ".sdkman/bin/sdkman-init.sh") -}}
export SDKMAN_DIR="$HOME/.sdkman"
source "#{{ .chezmoi.homeDir }}/.sdkman/bin/sdkman-init.sh"
#{{ end -}}

#{{ if and (lookPath "rvm") (stat (joinPath .chezmoi.homeDir ".rvm" "bin") ) -}}
if [[ ! "${PATH}" =~ ${HOME}/.rvm/bin ]]; then
    export PATH="$PATH:$HOME/.rvm/bin"
fi
#{{- end }}