Skip to content

Instantly share code, notes, and snippets.

@chinthakagodawita
Created July 21, 2015 13:12
Show Gist options
  • Save chinthakagodawita/03ff5495c3fff837aaed to your computer and use it in GitHub Desktop.
Save chinthakagodawita/03ff5495c3fff837aaed to your computer and use it in GitHub Desktop.
`php-version` in Fish
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