Created
July 12, 2016 18:16
-
-
Save tobias/aab714378333e8a7bbc40f4f1d621147 to your computer and use it in GitHub Desktop.
Manage multiple java versions on the mac from the fish shell
This file contains 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 setjdk | |
if test -n "$JAVA_HOME" | |
removeFromPath "$JAVA_HOME/bin" | |
end | |
set -gx JAVA_HOME (/usr/libexec/java_home -v $argv[1]) | |
set -gx PATH $JAVA_HOME/bin $PATH | |
end | |
function removeFromPath | |
set -l idx 0 | |
for x in (seq (count $PATH)) | |
if test "$argv[1]" = "$PATH[$x]" | |
set idx $x | |
end | |
end | |
if test $idx -gt 0 | |
set -e PATH[$idx] | |
end | |
end |
THANK YOU!
Thanks, that was very helpful.
I added another gist to list the versions you have installed (v simple compliment to your gist). Ok maybe overkill but well i forget the command and you don't have to go look in the dirs.
https://gist.github.com/kparmar1/297681c3c002e16d15a1fb2d75a02324
FYI: I enhanced the script to be able to pick versions (with a -t flag) that might be the same but from different vendors as well (Oracle, OpenJDK ...) .
https://gist.github.com/kparmar1/9dbe7bfcb46d71393d4d59607a747b5b
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you, you saved my day!