Export : Return old java export.

This commit is contained in:
Dmitry Voronin 2024-01-25 15:07:04 +03:00
parent 4a35591771
commit 85055e2e17

View file

@ -14,6 +14,9 @@ export MANPAGER="nvim +Man!"
# specify android sdk root. # specify android sdk root.
export ANDROID_SDK_ROOT="$HOME/.android/sdk" export ANDROID_SDK_ROOT="$HOME/.android/sdk"
# specify java path.
export JAVA_HOME="${HOME}/app/java/x64/latest"
# specify tex paths. # specify tex paths.
#export TEXMFSYSVAR="$HOME/app/tex/data/var" #export TEXMFSYSVAR="$HOME/app/tex/data/var"
#export TEXMFSYSCONFIG="$HOME/app/tex/data/config" #export TEXMFSYSCONFIG="$HOME/app/tex/data/config"
@ -25,14 +28,31 @@ export TEXMFLOCAL="${HOME}/app/tex/data/local"
export BASH_MODULE_PATH="${HOME}/.config/bash/module" export BASH_MODULE_PATH="${HOME}/.config/bash/module"
# Set java version. Sets to latest when not specified. # Set java version. Sets to latest when not specified.
# Usage: export_java <VERSION> # Usage: export_java [VERSION]
function export_java() { function export_java() {
local version="${1}" local version="${1}"
if [[ "${version}" = "" ]]; then if [[ "${version}" = "" ]]; then
help export_java export JAVA_HOME="${HOME}/app/java/x64/latest"
return 2 return
fi fi
export JAVA_HOME="$(find_nix openjdk-${version})" local available=($(_get_java_versions))
if ! _contains ${version} ${available[@]}; then
_error "Version ${version} is not available."
return 1
fi
export JAVA_HOME="${HOME}/app/java/x64/jdk_${version}"
} }
function _get_java_versions() {
ls "${HOME}/app/java/x64/" | grep "jdk_" | sed -e "s/.*_//" | sort -g 2> /dev/null
}
function _comp_java_versions() {
_autocomplete_first "$(_get_java_versions)"
}
complete -o nosort -F _comp_java_versions export_java