* .bashrc: Only source completions if available.
authorAmin Bandali <bandali@gnu.org>
Fri, 25 Nov 2022 23:55:14 +0000 (18:55 -0500)
committerAmin Bandali <bandali@gnu.org>
Sun, 27 Nov 2022 05:15:31 +0000 (00:15 -0500)
For both quilt and now pass-otp as well.

.bashrc

diff --git a/.bashrc b/.bashrc
index 87fdb99..5fb69fb 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -141,9 +141,19 @@ alias alert='notify-send --urgency=low \
 alias da='change-theme dark'
 alias li='change-theme light'
 
+bash_completions_dir=/usr/share/bash-completion/completions/
+
 alias dquilt="quilt --quiltrc=${XDG_CONFIG_HOME}/quilt/quiltrc-dpkg"
-. /usr/share/bash-completion/completions/quilt
-complete -F _quilt_completion -o filenames dquilt
+quilt_comps="${bash_completions_dir}/quilt"
+if [ -f "${quilt_comps}" ]; then
+     . "${quilt_comps}"
+     complete -F _quilt_completion -o filenames dquilt
+fi
+
+pass_otp_comps="${bash_completions_dir}/pass-otp"
+if [ -f "${pass_otp_comps}" ]; then
+     . "${pass_otp_comps}"
+fi
 
 function t {
   cd $(mktemp -d /tmp/$1.XXXX)