diff --git a/CHANGELOG.md b/CHANGELOG.md index d89de9c..11f0737 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Compatibility with SDKMAN! 5.9.2 - Completions for `env`, `home`, `flush` (issue #35) - Correct behaviour of `env clear`. - - TODO: autoenv (issue #38) + - Honor `sdkman_auto_env=true` (issue #38) - TODO: custom SDKMAN! install path (issue #34) - Compatibility with fisher 4 (PR #37, #39) diff --git a/conf.d/sdk.fish b/conf.d/sdk.fish index 270a018..bf4f1d6 100644 --- a/conf.d/sdk.fish +++ b/conf.d/sdk.fish @@ -83,3 +83,12 @@ if not set -q SDKMAN_DIR; or test (ls -ld "$SDKMAN_DIR" | awk '{print $3}') != ( __fish_sdkman_run_in_bash "source $__fish_sdkman_init" end +# Set up autoenv +if grep -q "^sdkman_auto_env=true" "$SDKMAN_DIR/etc/config" + function __fish_sdkman_autoenv --on-variable PWD + # Run the (modified) init script, which performs the checks and calls for us! + __fish_sdkman_run_in_bash "source \"$__fish_sdkman_noexport_init\"" + + set -x SDKMAN_OLD_PWD "$PWD" + end +end