From 42fa784644d1f16cfebc0706854f69383d6ec23d Mon Sep 17 00:00:00 2001 From: Eric Wagoner Date: Tue, 3 Mar 2026 09:26:37 -0500 Subject: [PATCH] Guard Docker init scripts with existence checks Prevents errors when Docker Desktop is not installed. Co-Authored-By: Claude Opus 4.6 --- bash_profile | 2 +- bashrc | 2 +- zshrc | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bash_profile b/bash_profile index 1ac8fd1..012b5ab 100644 --- a/bash_profile +++ b/bash_profile @@ -1 +1 @@ -source "$HOME/.docker/init-bash.sh" || true # Added by Docker Desktop +[[ -f "$HOME/.docker/init-bash.sh" ]] && source "$HOME/.docker/init-bash.sh" diff --git a/bashrc b/bashrc index 4f0d169..f86ddf2 100644 --- a/bashrc +++ b/bashrc @@ -3,7 +3,7 @@ export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion -source "$HOME/.docker/init-bash.sh" || true # Added by Docker Desktop +[[ -f "$HOME/.docker/init-bash.sh" ]] && source "$HOME/.docker/init-bash.sh" # Add RVM to PATH for scripting. Make sure this is the last PATH variable change. # export PATH="$PATH:$HOME/.rvm/bin" diff --git a/zshrc b/zshrc index a3cc2a7..327b594 100644 --- a/zshrc +++ b/zshrc @@ -130,7 +130,7 @@ export NVM_QUIET=1 typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet # Docker -source $HOME/.docker/init-zsh.sh || true +[[ -f "$HOME/.docker/init-zsh.sh" ]] && source "$HOME/.docker/init-zsh.sh" # iTerm2 integration test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh" @@ -157,8 +157,9 @@ alias nowdate='date +"%d-%m-%Y"' [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh -# The following lines have been added by Docker Desktop to enable Docker CLI completions. -fpath=($HOME/.docker/completions $fpath) +# Docker CLI completions +if [[ -d "$HOME/.docker/completions" ]]; then + fpath=($HOME/.docker/completions $fpath) +fi autoload -Uz compinit compinit -# End of Docker CLI completions