mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-29 06:40:08 +00:00
only show go_version segment if inside GOPATH
As of Go v1.8 GOPATH need not be set, as it will default to $HOME/go. By using `go env GOPATH` to retrieve the value first, this technique will work regardless of whether GOPATH is currently set by the user.
This commit is contained in:
parent
5a1d9ddb64
commit
f140104e4a
1 changed files with 3 additions and 1 deletions
|
@ -744,9 +744,11 @@ prompt_docker_machine() {
|
||||||
# GO prompt
|
# GO prompt
|
||||||
prompt_go_version() {
|
prompt_go_version() {
|
||||||
local go_version
|
local go_version
|
||||||
|
local go_path
|
||||||
go_version=$(go version 2>/dev/null | sed -E "s/.*(go[0-9.]*).*/\1/")
|
go_version=$(go version 2>/dev/null | sed -E "s/.*(go[0-9.]*).*/\1/")
|
||||||
|
go_path=$(go env GOPATH)
|
||||||
|
|
||||||
if [[ -n "$go_version" ]]; then
|
if [[ -n "$go_version" && "${PWD##$go_path}" != "$PWD" ]]; then
|
||||||
"$1_prompt_segment" "$0" "$2" "green" "255" "$go_version"
|
"$1_prompt_segment" "$0" "$2" "green" "255" "$go_version"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue