Skip to content

Commit

Permalink
Add MAMP's PHP to the only if MAMP is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
whatyouhide committed Sep 6, 2014
1 parent 1e43ed6 commit 11dfea7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
20 changes: 20 additions & 0 deletions zsh/lib/config-utils.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,23 @@ is-linux() {
false
fi
}

# Check if MAMP is installed on the system (which obviously has to be OSX).
is-mamp-installed() {
is-osx && [[ -d /Applications/MAMP ]]
}

# Return the path to the `bin/` directory of the latest version of the PHP
# shipped with MAMP.
mamp-latest-php-bin-dir() {
local _pwd=$(pwd)
local _mamp_php_dir='/Applications/MAMP/bin/php'
local _php_versions

cd "$_mamp_php_dir"
_php_versions=($(ls -d php*))
_php_latest="$_mamp_php_dir/"$_php_versions[-1]'/bin'
cd "$_pwd"

echo -n "$_php_latest"
}
26 changes: 15 additions & 11 deletions zsh/lib/path.zsh
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# Make sure that the PHP install in MAMP is the first one if we're on OSX.
is-osx && export PATH=/Applications/MAMP/bin/php/php5.5.10/bin
# Start with a clean slate, with only the scripts in the `bin` directory of the
# $DOTFILES.
PATH="$DOTFILES/bin"

# Standard PATH entries.
export PATH=$PATH:/usr/local/sbin
export PATH=$PATH:/usr/local/bin
export PATH=$PATH:/usr/bin
export PATH=$PATH:/usr/sbin
export PATH=$PATH:/bin
export PATH=$PATH:/sbin
export PATH="$PATH:/usr/local/sbin"
export PATH="$PATH:/usr/local/bin"
export PATH="$PATH:/usr/bin"
export PATH="$PATH:/usr/sbin"
export PATH="$PATH:/bin"
export PATH="$PATH:/sbin"

# RVM.
export PATH=$PATH:$HOME/.rvm/bin
export PATH="$PATH:$HOME/.rvm/bin"

# bin/ directory in the dotfiles.
export PATH=$PATH:$DOTFILES/bin
# Make sure that the PHP install in MAMP is the first one if we're on OSX and
# MAMP is installed.
if is-osx && is-mamp-installed; then
export PATH="$(mamp-latest-php-bin-dir):$PATH"
fi

0 comments on commit 11dfea7

Please sign in to comment.