Add Go version to prompt, only displayed when in a go source tree

This commit is contained in:
Greg Fitzgerald
2015-09-23 18:29:13 -04:00
committed by Caio Gondim
parent fd544cbb7a
commit a6c0510cc2
2 changed files with 38 additions and 0 deletions

View File

@@ -164,6 +164,15 @@ or don't want to see. All options must be overridden in your **.zshrc** file.
|`BULLETTRAIN_RUBY_FG`|`white`|Foreground color |`BULLETTRAIN_RUBY_FG`|`white`|Foreground color
|`BULLETTRAIN_RUBY_PREFIX`|`"♦"`|Prefix of the segment |`BULLETTRAIN_RUBY_PREFIX`|`"♦"`|Prefix of the segment
### Go
|Variable|Default|Meaning
|--------|-------|-------|
|`BULLETTRAIN_GO_SHOW`|`false`|Show/hide that segment
|`BULLETTRAIN_GO_BG`|`green`|Background color
|`BULLETTRAIN_GO_FG`|`white`|Foreground color
|`BULLETTRAIN_GO_PREFIX`|`""`|Prefix of the segment
### Dir ### Dir
|Variable|Default|Meaning |Variable|Default|Meaning

View File

@@ -96,6 +96,20 @@ if [ ! -n "${BULLETTRAIN_RUBY_PREFIX+1}" ]; then
BULLETTRAIN_RUBY_PREFIX=♦️ BULLETTRAIN_RUBY_PREFIX=♦️
fi fi
# Go
if [ ! -n "${BULLETTRAIN_GO_SHOW+1}" ]; then
BULLETTRAIN_GO_SHOW=true
fi
if [ ! -n "${BULLETTRAIN_GO_BG+1}" ]; then
BULLETTRAIN_GO_BG=cyan
fi
if [ ! -n "${BULLETTRAIN_GO_FG+1}" ]; then
BULLETTRAIN_GO_FG=white
fi
if [ ! -n "${BULLETTRAIN_GO_PREFIX+1}" ]; then
BULLETTRAIN_GO_PREFIX=
fi
# DIR # DIR
if [ ! -n "${BULLETTRAIN_DIR_SHOW+1}" ]; then if [ ! -n "${BULLETTRAIN_DIR_SHOW+1}" ]; then
BULLETTRAIN_DIR_SHOW=true BULLETTRAIN_DIR_SHOW=true
@@ -358,6 +372,20 @@ prompt_ruby() {
fi fi
} }
# Go
prompt_go() {
if [[ $BULLETTRAIN_GO_SHOW == false ]]; then
return
fi
setopt extended_glob
if [[ (-f *.go(#qN) || -d Godeps) ]]; then
if command -v go > /dev/null 2>&1; then
prompt_segment $BULLETTRAIN_GO_BG $BULLETTRAIN_GO_FG $BULLETTRAIN_GO_PREFIX"$(go version | grep -oE 'go[[:digit:]].[[:digit:]]')"
fi
fi
}
# Virtualenv: current working virtualenv # Virtualenv: current working virtualenv
prompt_virtualenv() { prompt_virtualenv() {
if [[ $BULLETTRAIN_VIRTUALENV_SHOW == false ]]; then if [[ $BULLETTRAIN_VIRTUALENV_SHOW == false ]]; then
@@ -460,6 +488,7 @@ build_prompt() {
prompt_ruby prompt_ruby
prompt_virtualenv prompt_virtualenv
prompt_nvm prompt_nvm
prompt_go
prompt_context prompt_context
prompt_dir prompt_dir
prompt_git prompt_git