aboutsummaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-05-22 14:58:45 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-05-22 14:58:45 +0300
commit5b703c0db04c2eda8793da26d2d709ba38619adc (patch)
treef6f125d6c6b061d1b7b77ac2caa88d1dba3da973 /powerlevel9k.zsh-theme
parent4a3b62cde90bdfdfe7ce5eeb7ccce54d1facf922 (diff)
speed up swift_version prompt
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme9
1 files changed, 4 insertions, 5 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index fec9e05e..9ec8ad65 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -2039,11 +2039,10 @@ prompt_openfoam() {
################################################################
# Segment to display Swift version
prompt_swift_version() {
- # Get the first number as this is probably the "main" version number..
- local swift_version=$(swift --version 2>/dev/null | grep -o -E "[0-9.]+" | head -n 1)
- [[ -z "${swift_version}" ]] && return
-
- "$1_prompt_segment" "$0" "$2" "magenta" "white" 'SWIFT_ICON' 0 '' "${swift_version//\%/%%}"
+ _p9k_cached_cmd_stdout swift --version || return
+ emulate -L zsh && setopt extendedglob
+ [[ $_P9K_RETVAL == (#b)[^[:digit:]]#([[:digit:].]##)* ]] || return
+ "$1_prompt_segment" "$0" "$2" "magenta" "white" 'SWIFT_ICON' 0 '' "${match[1]//\%/%%}"
}
################################################################