Skip to content

Instantly share code, notes, and snippets.

@inoperable
Last active November 2, 2020 10:14
Show Gist options
  • Save inoperable/8d29907bd58d1298207b3a70960ec03a to your computer and use it in GitHub Desktop.
Save inoperable/8d29907bd58d1298207b3a70960ec03a to your computer and use it in GitHub Desktop.

Revisions

  1. inoperable renamed this gist Nov 2, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. inoperable created this gist Nov 2, 2020.
    10 changes: 10 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # 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 {}"
    }