diff options
author | Jason Hutchinson <zikes@zikes.me> | 2017-04-07 07:17:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-07 07:17:32 +0300 |
commit | f140104e4a6cbe419f957c761884d279dbcfeb8a (patch) | |
tree | b0635b729c9422f5bf8e880dc1c61c32d71cdc91 | |
parent | 5a1d9ddb6494d4f8eddc24490dde191a1f06088a (diff) |
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.
-rwxr-xr-x | powerlevel9k.zsh-theme | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index bbd1ec44..09ce6b3d 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -744,9 +744,11 @@ prompt_docker_machine() { # GO prompt prompt_go_version() { local go_version + local go_path 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" fi } |