diff --git a/segments/go_version/README.md b/segments/go_version/README.md index bf70e79e3..a6b72f174 100644 --- a/segments/go_version/README.md +++ b/segments/go_version/README.md @@ -10,6 +10,18 @@ where you want to show this segment. ## Configuration +This segment shows the version of Go installed. + +It figures out the version being used by taking the output of the `go version` command. + +* If `go` is not in $PATH, nothing will be shown. +* By default, if the current Go version is only shown while inside your GOPATH. See the configuration variable, below, to modify this behavior. + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`P9K_GO_VERSION_PROMPT_ALWAYS_SHOW` |`false`|Set to true if you wish to show the go_version segment even if you're not inside your GOPATH. | + + ### Color Customization You can change the foreground and background color of this segment by setting @@ -21,4 +33,4 @@ P9K_GO_VERSION_BACKGROUND='blue' ### Customize Icon The main Icon can be changed by setting `P9K_GO_VERSION_ICON="my_icon"`. To change the -icon color only, set `P9K_GO_VERSION_ICON_COLOR="red"`. \ No newline at end of file +icon color only, set `P9K_GO_VERSION_ICON_COLOR="red"`. diff --git a/segments/go_version/go_version.p9k b/segments/go_version/go_version.p9k index ea163adf2..7424a2902 100644 --- a/segments/go_version/go_version.p9k +++ b/segments/go_version/go_version.p9k @@ -12,7 +12,11 @@ # Parameters: # segment_name context background foreground Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #   - p9k::register_segment "GO_VERSION" '' 'green' 'grey93' 'Go' '' '' '\u'${CODEPOINT_OF_DEVICONS_GIT_PULL_REQUEST} $'\uE626' + p9k::register_segment "GO_VERSION" '' 'cyan' 'black' 'Go' '' '' '\u'${CODEPOINT_OF_DEVICONS_GIT_PULL_REQUEST} $'\uE626' + + ################################################################ + # Register segment default values + p9k::set_default P9K_GO_VERSION_PROMPT_ALWAYS_SHOW false } ################################################################ @@ -27,10 +31,10 @@ prompt_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/; s/go//g') go_path=$(go env GOPATH 2>/dev/null) - if [[ -n "$go_version" && "${PWD##$go_path}" != "$PWD" ]]; then + if [[ -n "$go_version" && "${PWD##$go_path}" != "$PWD" || "${P9K_GO_VERSION_PROMPT_ALWAYS_SHOW}" == "true" ]]; then p9k::prepare_segment "$0" "" $1 "$2" $3 "$go_version" fi } diff --git a/segments/go_version/go_version.spec b/segments/go_version/go_version.spec index c84fd8b5c..ca53d293d 100755 --- a/segments/go_version/go_version.spec +++ b/segments/go_version/go_version.spec @@ -44,7 +44,7 @@ function testGo() { PWD="$HOME/go/src/github.com/bhilburn/powerlevel9k" - assertEquals "%K{002} %F{255}Go %F{255}go1.5.3 %k%F{002}%f " "$(__p9k_build_left_prompt)" + assertEquals "%K{006} %F{000}Go %F{000}1.5.3 %k%F{006}%f " "$(__p9k_build_left_prompt)" unset P9K_GO_ICON unset PWD diff --git a/segments/go_version/segment.png b/segments/go_version/segment.png index d7e4b84fe..ee0387a2a 100644 Binary files a/segments/go_version/segment.png and b/segments/go_version/segment.png differ diff --git a/segments/go_version/segment.svg b/segments/go_version/segment.svg index 0c610892b..83291e624 100644 --- a/segments/go_version/segment.svg +++ b/segments/go_version/segment.svg @@ -113,7 +113,7 @@  go1.5.3 + sodipodi:role="line"> 1.12.1