mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2025-01-19 04:47:40 +02:00
speed up go_version prompt
This commit is contained in:
parent
5800b79f51
commit
fed768479f
@ -996,11 +996,14 @@ prompt_docker_machine() {
|
|||||||
################################################################
|
################################################################
|
||||||
# GO prompt
|
# GO prompt
|
||||||
prompt_go_version() {
|
prompt_go_version() {
|
||||||
local go_version=$(go version 2>/dev/null | sed -E "s/.*(go[0-9.]*).*/\1/")
|
_p9k_cached_cmd_stdout go version || return
|
||||||
local go_path=$(go env GOPATH 2>/dev/null)
|
emulate -L zsh && setopt extendedglob
|
||||||
if [[ -n "$go_version" && "${PWD##$go_path}" != "$PWD" ]]; then
|
local -a match
|
||||||
"$1_prompt_segment" "$0" "$2" "green" "grey93" "GO_ICON" 0 '' "${go_version//\%/%%}"
|
[[ $_P9K_RETVAL == (#b)*(go[0-9.]##)* ]] || return
|
||||||
fi
|
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//\%/%%}"
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user