blob: 9e5cfdc2e510a9284c44ad0179ebd98cfda0b3d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#
# Go
#
# Go is an open source programming language that makes it easy
# to build efficient software.
# Link: https://golang.org/
# ------------------------------------------------------------------------------
# Configuration
# ------------------------------------------------------------------------------
SPACESHIP_GOLANG_SHOW="${SPACESHIP_GOLANG_SHOW=true}"
SPACESHIP_GOLANG_PREFIX="${SPACESHIP_GOLANG_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_GOLANG_SUFFIX="${SPACESHIP_GOLANG_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_GOLANG_SYMBOL="${SPACESHIP_GOLANG_SYMBOL="🐹 "}"
SPACESHIP_GOLANG_COLOR="${SPACESHIP_GOLANG_COLOR="cyan"}"
# ------------------------------------------------------------------------------
# Section
# ------------------------------------------------------------------------------
spaceship_golang() {
[[ $SPACESHIP_GOLANG_SHOW == false ]] && return
# If there are Go-specific files in current directory, or current directory is under the GOPATH
[[ -f go.mod || -d Godeps || -f glide.yaml || -n *.go(#qN^/) || -f Gopkg.toml || -f Gopkg.lock \
|| ( $GOPATH && "$PWD/" =~ "$GOPATH/" ) ]] || return
spaceship::exists go || return
# Go version is either the commit hash and date like "devel +5efe9a8f11 Web Jan 9 07:21:16 2019 +0000"
# at the time of the build or a release tag like "go1.11.4".
# https://github.com/spaceship-prompt/spaceship-prompt/issues/610
local go_version=$(go version | awk '{ if ($3 ~ /^devel/) {print $3 ":" substr($4, 2)} else {print "v" substr($3, 3)} }')
spaceship::section \
"$SPACESHIP_GOLANG_COLOR" \
"$SPACESHIP_GOLANG_PREFIX" \
"${SPACESHIP_GOLANG_SYMBOL}${go_version}" \
"$SPACESHIP_GOLANG_SUFFIX"
}
|