Export : Update for Nix.
This commit is contained in:
parent
1ea36ef9d3
commit
b057f47294
|
@ -11,9 +11,6 @@ export EDITOR=nvim
|
|||
# specify man page viewer.
|
||||
export MANPAGER="nvim +Man!"
|
||||
|
||||
# specify java path.
|
||||
export JAVA_HOME="${HOME}/app/java/x64/latest"
|
||||
|
||||
# specify android sdk root.
|
||||
export ANDROID_SDK_ROOT="$HOME/.android/sdk"
|
||||
|
||||
|
@ -28,31 +25,14 @@ export TEXMFLOCAL="${HOME}/app/tex/data/local"
|
|||
export BASH_MODULE_PATH="${HOME}/.config/bash/module"
|
||||
|
||||
# Set java version. Sets to latest when not specified.
|
||||
# Usage: export_java [VERSION]
|
||||
# Usage: export_java <VERSION>
|
||||
function export_java() {
|
||||
local version="${1}"
|
||||
|
||||
if [[ "${version}" = "" ]]; then
|
||||
export JAVA_HOME="${HOME}/app/java/x64/latest"
|
||||
return
|
||||
help export_java
|
||||
return 2
|
||||
fi
|
||||
|
||||
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}"
|
||||
export JAVA_HOME="$(find_nix openjdk-${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
|
||||
|
|
19
.config/bash/module/Nix.sh
Normal file
19
.config/bash/module/Nix.sh
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Find Nix package path.
|
||||
# Usage: find_nix <PACKAGE>
|
||||
function find_nix() {
|
||||
local IFS=$'\n'
|
||||
local package="${1}"
|
||||
|
||||
if [[ "${package}" = "" ]]; then
|
||||
help find_nix
|
||||
return 2
|
||||
fi
|
||||
|
||||
local found=$(ls --classify /nix/store/ | grep "${package}".*/)
|
||||
|
||||
if [[ "${found}" != "" ]]; then
|
||||
echo "/nix/store/${found%/}"
|
||||
else
|
||||
false
|
||||
fi
|
||||
}
|
Reference in a new issue