summaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-05-21 14:21:22 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-05-21 14:21:22 +0300
commitfed768479f8fedb28766927d914b007983d71a04 (patch)
treec656a2502d91827f13df4efcef39f1c1a7a76e0c /powerlevel9k.zsh-theme
parent5800b79f513171078aed01aaf434937c25d6c172 (diff)
speed up go_version prompt
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme13
1 files changed, 8 insertions, 5 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index ef99f010..17c780e3 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -996,11 +996,14 @@ prompt_docker_machine() {
################################################################
# GO prompt
prompt_go_version() {
- local go_version=$(go version 2>/dev/null | sed -E "s/.*(go[0-9.]*).*/\1/")
- local go_path=$(go env GOPATH 2>/dev/null)
- if [[ -n "$go_version" && "${PWD##$go_path}" != "$PWD" ]]; then
- "$1_prompt_segment" "$0" "$2" "green" "grey93" "GO_ICON" 0 '' "${go_version//\%/%%}"
- fi
+ _p9k_cached_cmd_stdout go version || return
+ emulate -L zsh && setopt extendedglob
+ local -a match
+ [[ $_P9K_RETVAL == (#b)*(go[0-9.]##)* ]] || return
+ local v=$match[1]
+ local p=${GOPATH:-$(go env GOPATH 2>/dev/null)}
+ [[ -n $p && $PWD/ == $p/* ]] || return
+ "$1_prompt_segment" "$0" "$2" "green" "grey93" "GO_ICON" 0 '' "${v//\%/%%}"
}
################################################################