Last active
November 10, 2024 04:37
-
-
Save pawann-2000/9976d1eab61c0f10373115c160f5914d to your computer and use it in GitHub Desktop.
While SDKMAN! is primarily designed for Bash/Zsh shells, you can make it work with Fish shell using a simple wrapper function that bridges the gap between Fish and Bash.
This file contains hidden or 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
| # Save this as ~/.config/fish/conf.d/sdkman.fish | |
| function sdk --description 'SDKMAN! wrapper for Fish shell' | |
| set -q SDKMAN_DIR; or set -gx SDKMAN_DIR "$HOME/.sdkman" | |
| set -q SDKMAN_CANDIDATES_API; or set -gx SDKMAN_CANDIDATES_API "https://api.sdkman.io/2" | |
| if test -f "$SDKMAN_DIR/var/platform" | |
| set -gx SDKMAN_PLATFORM (cat "$SDKMAN_DIR/var/platform") | |
| end | |
| command bash -c "source $SDKMAN_DIR/bin/sdkman-init.sh && sdk $argv" | |
| if contains -- "$argv[1]" "install" "uninstall" "use" "default" "env" | |
| set -l candidates (cat "$SDKMAN_DIR/var/candidates") | |
| for candidate in (string split ',' $candidates) | |
| set -l candidate_dir "$SDKMAN_DIR/candidates/$candidate/current" | |
| if test -L "$candidate_dir"; or test -d "$candidate_dir" | |
| if not contains "$candidate_dir/bin" $PATH | |
| set -gx PATH "$candidate_dir/bin" $PATH | |
| end | |
| end | |
| end | |
| end | |
| end | |
| complete -c sdk -f | |
| complete -c sdk -a "install uninstall list use current upgrade version default home env clear help offline selfupdate update flush" -d "SDKMAN! command" | |
| complete -c sdk -n "__fish_seen_subcommand_from install uninstall list use current upgrade version default home" -a "(cat $HOME/.sdkman/var/candidates | string split ',')" -d "SDK candidate" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment