Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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...
commit 99885c1d1f235fdda181ac7028c205d9b583ed8c 1 parent 0713324
@necolas authored
Showing with 14 additions and 7 deletions.
  1. +8 −0 README.md
  2. +3 −2 bash/bash_profile
  3. +3 −5 bash/exports
View
8 README.md
@@ -59,6 +59,14 @@ cd ~/.dotfiles
bash script/homebrew
```
+If your Homebrew installation is not in `usr/local` then you must add your
+custom location's `bin` to your PATH in your `.bash_profile.local`:
+
+```bash
+# Add `brew` command's custom location to PATH
+PATH="/opt/acme/bin:$PATH"
+```
+
## Adding local and private configurations
View
5 bash/bash_profile
@@ -10,8 +10,6 @@ FILES="$FILES $HOME/.dotfiles/bash/aliases"
FILES="$FILES $HOME/.dotfiles/bash/functions"
# Custom Bash prompt
FILES="$FILES $HOME/.dotfiles/bash/bash_prompt"
-# Git Bash completion (comes with Homebrew git installation)
-FILES="$FILES `brew --prefix`/etc/bash_completion.d/git-completion.bash"
# 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 "$(brew --prefix)/etc/bash_completion.d/git-completion.bash" ] && source "$(brew --prefix)/etc/bash_completion.d/git-completion.bash"
+
# Case-insensitive globbing (used in pathname expansion)
shopt -s nocaseglob
View
8 bash/exports
@@ -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";
-
export PATH
Please sign in to comment.
Something went wrong with that request. Please try again.