mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-22 12:20:07 +00:00
speed up java_version prompt
This commit is contained in:
parent
1062033184
commit
7ca1d950f1
1 changed files with 5 additions and 11 deletions
|
@ -2090,17 +2090,11 @@ prompt_dropbox() {
|
||||||
|
|
||||||
# print Java version number
|
# print Java version number
|
||||||
prompt_java_version() {
|
prompt_java_version() {
|
||||||
local java_version
|
(( $+commands[java] )) || return
|
||||||
# Stupid: Java prints its version on STDERR.
|
local v && v=$(java -fullversion 2>&1) || return
|
||||||
# The first version ouput will print nothing, we just
|
v=${${v#*\"}%\"*}
|
||||||
# use it to transport whether the command was successful.
|
[[ -n $v ]] || return
|
||||||
# If yes, we parse the version string (and need to
|
"$1_prompt_segment" "$0" "$2" "red" "white" "JAVA_ICON" 0 '' "${v//\%/%%}"
|
||||||
# redirect the stderr to stdout to make the pipe work).
|
|
||||||
java_version=$(java -version 2>/dev/null && java -fullversion 2>&1 | cut -d '"' -f 2)
|
|
||||||
|
|
||||||
if [[ -n "$java_version" ]]; then
|
|
||||||
"$1_prompt_segment" "$0" "$2" "red" "white" "JAVA_ICON" 0 '' "${java_version//\%/%%}"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
|
|
Loading…
Reference in a new issue