Skip to content

Conversation

Wingless-Archangel
Copy link

the current version is 1.10.1 which will cause the new line in the matching pattern as shown below.

$ go version | grep -oE "[[:digit:]].[[:digit:]]"
1.1
0.1

to fix this issue, changing to pure cut command in the request.

Copy link

@salmanulfarzy salmanulfarzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using awk instead of two cut commands.

if [[ (-f *.go(#qN) || -d Godeps || -f glide.yaml) ]]; then
if command -v go > /dev/null 2>&1; then
prompt_segment $BULLETTRAIN_GO_BG $BULLETTRAIN_GO_FG $BULLETTRAIN_GO_PREFIX" $(go version | grep --colour=never -oE '[[:digit:]].[[:digit:]]')"
prompt_segment $BULLETTRAIN_GO_BG $BULLETTRAIN_GO_FG $BULLETTRAIN_GO_PREFIX" $(go version |cut -d ' ' -f3 | cut -c '3-')"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could get go version with only awk

go version | awk '{print substr($3, 3)}'

@Wingless-Archangel
Copy link
Author

Wingless-Archangel commented Apr 6, 2018 via email

change the code as caiogondim#273 (review) recommend
@Wingless-Archangel
Copy link
Author

Duplicate with #264

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants