asdf-java/set-java-home.fish
Matt Tanous f4fabebf39
Another fix for setting JAVA_HOME in fish shell (#134)
* Use fish builtin `realpath`

* Specify use of builtin fish realpath

* Add a second dirname for fish shell
2021-03-09 11:18:51 -05:00

11 lines
389 B
Fish

function asdf_update_java_home --on-event fish_prompt
set --local java_path (asdf which java)
if test -n "$java_path"
set --local full_path (builtin realpath "$java_path")
# `builtin realpath` returns $JAVA_HOME/bin/java, so we need two `dirname` calls
# in order to get the correct JAVA_HOME directory
set -gx JAVA_HOME (dirname (dirname "$full_path"))
end
end