Created
May 23, 2014 15:05
-
-
Save pyk/ab63cfbd53668c3eed50 to your computer and use it in GitHub Desktop.
How to: display Go lang version on Bash prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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