Skip to content

Instantly share code, notes, and snippets.

@inoperable
Last active November 2, 2020 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inoperable/8d29907bd58d1298207b3a70960ec03a to your computer and use it in GitHub Desktop.
Save inoperable/8d29907bd58d1298207b3a70960ec03a to your computer and use it in GitHub Desktop.
sdkman to fzf quick and dirty selection of installed JDKS with fzf in zsh (should work also in bash, i guess)
# assuming sdkman is installed in default location: $HOME/.sdkman
# grep selects only from INSTALLED candidates
#
# add to your .zshrc or .zshrc.local or save it as use-jdk.zsh and
# load it on init with 'source ~/PATH/TO/SCRIPT/use-jdk.zsh'
function use-jdk() {
FUNCS=$(functions sdk);
sdk ls java | grep installed | grep -Po "\|\s\d+.*|" | gawk '{ print $8 }' | fzf -e | xargs -I{} zsh -c "eval $FUNCS; . ~/.sdkman/bin/sdkman-init.sh; sdk default java {}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment