Skip to content

Instantly share code, notes, and snippets.

@aizatto
Created July 2, 2017 06:20
Show Gist options
  • Save aizatto/2a097285e09f04beb2a3af56a2277f5e to your computer and use it in GitHub Desktop.
Save aizatto/2a097285e09f04beb2a3af56a2277f5e to your computer and use it in GitHub Desktop.
Display node version in bash prompt
_node_version()
{
local br
br=$(node -v)
test -n "$br" && printf %s "$br" || :
}
green=$'\e[1;32m'
magenta=$'\e[1;35m'
normal_colours=$'\e[m'
PS1="${PS1:0:$((${#PS1} - 2))} \[$magenta\]\$(_node_version)\[$normal_colours\]\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment