Created
July 21, 2015 13:12
-
-
Save chinthakagodawita/03ff5495c3fff837aaed to your computer and use it in GitHub Desktop.
`php-version` in Fish
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function php-version | |
set -l env_file (mktemp -t php-version.fish.XXXXXXXXXX) | |
bash -c 'echo "$@"; source $(brew --prefix php-version)/php-version.sh; php-version "$@"; status=$?; env > "$0"; exit $status' $env_file $argv | |
# apply php-version_* and *PATH variables from the captured environment | |
echo (cat $env_file) | |
# and eval (grep '^php-version\|^[^=]*PATH' $env_file | sed '/^[^=]*PATH/y/:/ /; s/^/set -xg /; s/=/ /; s/$/ ;/; s/(//; s/)//') | |
# clean up | |
rm -f $env_file | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment