Skip to content

Instantly share code, notes, and snippets.

@pyk
Created May 23, 2014 15:05
Show Gist options
  • Save pyk/ab63cfbd53668c3eed50 to your computer and use it in GitHub Desktop.
Save pyk/ab63cfbd53668c3eed50 to your computer and use it in GitHub Desktop.
How to: display Go lang version on Bash prompt
# add this function on your .bashrc file to echoed Go version
function go_version {
version=$(go version)
regex="(go[0-9].[0-9].[0-9])"
if [[ $version =~ $regex ]]; then
echo ${BASH_REMATCH[1]}
fi
}
# and add to your PS1, for example
# PS1="$(go_version) $ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment