diff options
author | romkatv <roman.perepelitsa@gmail.com> | 2019-05-22 20:59:58 +0300 |
---|---|---|
committer | romkatv <roman.perepelitsa@gmail.com> | 2019-05-22 20:59:58 +0300 |
commit | 7ca1d950f1eb759812248a569090656e00afb525 (patch) | |
tree | 8213a1cb414c84a0e0138a5ef62b4a70399e1e3c /powerlevel9k.zsh-theme | |
parent | 10620331848ffc75253370bf91d9d6b2810ac553 (diff) |
speed up java_version prompt
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 59da4366..72757560 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -2090,17 +2090,11 @@ prompt_dropbox() { # print Java version number prompt_java_version() { - local java_version - # Stupid: Java prints its version on STDERR. - # The first version ouput will print nothing, we just - # use it to transport whether the command was successful. - # If yes, we parse the version string (and need to - # 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 + (( $+commands[java] )) || return + local v && v=$(java -fullversion 2>&1) || return + v=${${v#*\"}%\"*} + [[ -n $v ]] || return + "$1_prompt_segment" "$0" "$2" "red" "white" "JAVA_ICON" 0 '' "${v//\%/%%}" } ################################################################ |