Reputation: 63
I want to update my fish shell to use the current version of php from MAMP (which ever version is currently in use).
I found an excellent article on how to do this in bash, but I can't seem to work out how to achieve this in fish?
The article is: How to override the path of PHP to use the MAMP path?
Specifically:
# Use MAMP version of PHP
PHP_VERSION=`ls /Applications/MAMP/bin/php/ | sort -n | tail -1`
export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH
How do you achieve this in fish? Fish wants to export PHP_VERSION
as a string.
And also using these commmand alias's to use current version of MySQL
# Export MAMP MySQL executables as functions
# Makes them usable from within shell scripts (unlike an alias)
mysql() {
/Applications/MAMP/Library/bin/mysql "$@"
}
mysqladmin() {
/Applications/MAMP/Library/bin/mysqladmin "$@"
}
export -f mysql
export -f mysqladmin
I have tried to figure out the various pieces of this, but having limited understanding of commandline makes it difficult to know what to 'search' for.
Appreciate any help!
Upvotes: 2
Views: 9687
Reputation: 18551
Setting PATH is covered in the fish tutorial.
Ordinarily you could simply modify fish_user_paths
, but since you want the path to be dynamically determined on every launch, it's simpler to set PATH directly. A straightforward translation:
set PHP_VERSION (ls /Applications/MAMP/bin/php/ | sort -n | tail -1)
set -x PATH /Applications/MAMP/bin/php/$PHP_VERSION/bin $PATH
You would put that in ~/.config/fish/fish.config
Regarding "exporting functions", this was always a suspicious idea (it was the source of that terrible bash security hole) and is not something that fish supports. You should just instead arrange for /Applications/MAMP/Library/bin/mysql
to be in PATH, so that child scripts can find your executables. Just like before:
set -x PATH /Applications/MAMP/Library/bin/ $PATH
Upvotes: 8