From e354f8abe6985e8a2b323de88370d4258867eb6a Mon Sep 17 00:00:00 2001 From: Raphael Reitzig <4246780+reitzig@users.noreply.github.com> Date: Mon, 16 Jul 2018 12:30:49 +0200 Subject: [PATCH] Search for installed candidates now handles non-standard $HOME. Fixes issue #14. --- completions/sdk.fish | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/completions/sdk.fish b/completions/sdk.fish index e96e911..1b9e393 100644 --- a/completions/sdk.fish +++ b/completions/sdk.fish @@ -73,19 +73,21 @@ end # # # # # # function __fish_sdkman_candidates - cat ~/.sdkman/var/candidates | tr ',' '\n' + cat "$HOME"/.sdkman/var/candidates | tr ',' '\n' end function __fish_sdkman_candidates_with_versions - find ~/.sdkman/candidates/ -name '*current*' -printf "%h\n" \ - | cut -d '/' -f 6 \ + set regexpHome (string replace -a '/' '\\/' "$HOME/") + find "$HOME"/.sdkman/candidates/ -name '*current*' -printf "%h\n" \ + | sed -e "s/$regexpHome//" \ + | cut -d '/' -f 3 \ | sort -u end function __fish_sdkman_installed_versions set cmd (commandline -opc) - if [ -d ~/.sdkman/candidates/$cmd[3]/current ] - ls -v1 ~/.sdkman/candidates/$cmd[3] | grep -v current + if [ -d "$HOME"/.sdkman/candidates/$cmd[3]/current ] + ls -v1 "$HOME"/.sdkman/candidates/$cmd[3] | grep -v current end end