bash: fix to work with custom `brew` location
A bug in the previous commit meant that when Homebrew was installed in a
custom location, there were references to `brew --prefix` before `brew`
was added to the PATH.
The solution in this commit is to ask the user to add the custom `bin`
location to their PATH in `.bash_profile.local`. Then any references to
`brew --prefix` are avoided until `.bash_profile.local` is sourced in
`.bash_profile`. This avoids errors.
Loading branch information
3 changed files
and 7 deletions.
@@ -59,6 +59,14 @@ cd ~/.dotfiles
+If your Homebrew installation is not in
`usr/local` then you must add your
`bin` to your PATH in your `.bash_profile.local`:
# Add `brew` command's custom location to PATH
PATH= "/opt/acme/bin: $PATH "
## Adding local and private configurations
@@ -10,8 +10,6 @@ FILES="$FILES $HOME/.dotfiles/bash/aliases"
" $FILES $HOME/.dotfiles/bash/functions "
# Custom Bash prompt
" $FILES $HOME/.dotfiles/bash/bash_prompt "
# Git Bash completion (comes with Homebrew git installation)
" $FILES /etc/bash_completion.d/git-completion.bash `brew --prefix ` "
# Source all readable files in FILES
for file in $FILES
@@ -22,6 +20,9 @@ done
# Load RVM into a shell session *as a function*
-s ]] " $HOME/.rvm/scripts/rvm " && source " $HOME/.rvm/scripts/rvm "
# Git Bash completion (comes with Homebrew git installation; source after `brew` is added to PATH)
-r ] " /etc/bash_completion.d/git-completion.bash $(brew --prefix ) " && source " /etc/bash_completion.d/git-completion.bash $(brew --prefix ) "
# Case-insensitive globbing (used in pathname expansion)
shopt -s nocaseglob
@@ -11,6 +11,9 @@ export HISTCONTROL=ignoredups
# Make some commands not show up in history
export HISTIGNORE="ls:ls *:cd:cd -:pwd;exit:date:* --help"
+# Move to the beginning of PATH so that it always take precedence over /usr/bin
+[ -d "/usr/local/bin" ] && PATH="/usr/local/bin:$PATH";
# If these bins exist, then add them to the PATH
[ -d "/usr/bin" ] && PATH="$PATH:/usr/bin";
[ -d "$HOME/bin" ] && PATH="$PATH:$HOME/bin";
@@ -19,9 +22,4 @@ export HISTIGNORE="ls:ls *:cd:cd -:pwd;exit:date:* --help"
# Add brew-installed GNU core utilities bin
[ -d "$(brew --prefix coreutils)/libexec/gnubin" ] && PATH="$PATH:$(brew --prefix coreutils)/libexec/gnubin";
-# Add to beginning of PATH so that it always take precedence over /usr/bin
-[ -d "/usr/local/bin" ] && PATH="/usr/local/bin:$PATH";
-# If Homebrew is installed in a custom directory, this will add another bin to the PATH
-[ -d "$(brew --prefix)/bin" ] && PATH="$(brew --prefix)/bin:$PATH";