show non-default rvm gemset in PS1

This commit is contained in:
Josh Holtrop 2019-08-28 12:12:30 -04:00
parent fea9c018a4
commit 77c910a16f

View File

@ -119,9 +119,9 @@ function prompt_ps1_git_branch()
function prompt_ps1_svn_branch() function prompt_ps1_svn_branch()
{ {
if [ -e .svn ]; then if [ -e .svn ]; then
url_out=$(command svn info 2>/dev/null | grep '^URL:') local url_out=$(command svn info 2>/dev/null | grep '^URL:')
re_branch="\\<(tags|branches)/([^/]*)\\>" local re_branch="\\<(tags|branches)/([^/]*)\\>"
re_trunk="\\<trunk\\>" local re_trunk="\\<trunk\\>"
if [[ "$url_out" =~ $re_branch ]]; then if [[ "$url_out" =~ $re_branch ]]; then
echo "${BASH_REMATCH[2]} " echo "${BASH_REMATCH[2]} "
elif [[ "$url_out" =~ $re_trunk ]]; then elif [[ "$url_out" =~ $re_trunk ]]; then
@ -130,6 +130,14 @@ function prompt_ps1_svn_branch()
fi fi
} }
function prompt_ps1_rvm_gemset()
{
local re="rvm.*@(.*)"
if [[ "$GEM_HOME" =~ $re ]]; then
echo "${BASH_REMATCH[1]} "
fi
}
# elapsed time # elapsed time
PS1="$(ps-color bold blue)\$(prompt_ps1_elapsed_time \D{%s})" PS1="$(ps-color bold blue)\$(prompt_ps1_elapsed_time \D{%s})"
# exit status # exit status
@ -149,6 +157,8 @@ PS1="${PS1}$(ps-color bold blue)\$(prompt_ps1_job_count \\j)"
PS1="${PS1}$(ps-color bold green)\$(prompt_ps1_shlvl)" PS1="${PS1}$(ps-color bold green)\$(prompt_ps1_shlvl)"
# \n # \n
PS1="${PS1}$(ps-color reset)\n" PS1="${PS1}$(ps-color reset)\n"
# rvm gemset
PS1="${PS1}$(ps-color bold green)\$(prompt_ps1_rvm_gemset)"
# git/svn info # git/svn info
PS1="${PS1}$(ps-color bold yellow)\$(prompt_ps1_git_branch)\$(prompt_ps1_svn_branch)" PS1="${PS1}$(ps-color bold yellow)\$(prompt_ps1_git_branch)\$(prompt_ps1_svn_branch)"
# dollar # dollar