bash_aliases: show nested shell level in prompt

This commit is contained in:
Josh Holtrop 2018-06-18 17:11:55 -04:00
parent 8628b1d82b
commit 3a4753cabb

View File

@ -66,6 +66,13 @@ function prompt_ps1_job_count()
fi fi
} }
function prompt_ps1_shlvl()
{
if [ "$SHLVL" -ne 1 ]; then
echo " *$SHLVL"
fi
}
function prompt_ps1_git_branch() function prompt_ps1_git_branch()
{ {
local git_branch_out local git_branch_out
@ -105,9 +112,9 @@ function prompt_ps1_svn_branch()
} }
if [[ "${USER}" == "root" ]]; then if [[ "${USER}" == "root" ]]; then
PS1="$(ps-color bold white on-red)\$(prompt_ps1_exit_status_1)$(ps-color reset)\$(prompt_ps1_exit_status_2)$(ps-color bold red)\u@\H$(ps-color bold green) [\w]$(ps-color bold magenta) \d \t$(ps-color bold blue)\$(prompt_ps1_job_count \\j)\n\$ $(ps-color reset)" PS1="$(ps-color bold white on-red)\$(prompt_ps1_exit_status_1)$(ps-color reset)\$(prompt_ps1_exit_status_2)$(ps-color bold red)\u@\H$(ps-color bold green) [\w]$(ps-color bold magenta) \d \t$(ps-color bold blue)\$(prompt_ps1_job_count \\j)$(ps-color bold cyan)\$(prompt_ps1_shlvl)$(ps-color reset)\n\$ "
else else
PS1="$(ps-color bold white on-red)\$(prompt_ps1_exit_status_1)$(ps-color reset)\$(prompt_ps1_exit_status_2)$(ps-color bold green)\u@\H$(ps-color bold red) [\w]$(ps-color bold magenta) \d \t$(ps-color bold blue)\$(prompt_ps1_job_count \\j)$(ps-color bold yellow)\$(prompt_ps1_git_branch)\$(prompt_ps1_svn_branch)$(ps-color bold blue)\n\$ $(ps-color reset)" PS1="$(ps-color bold white on-red)\$(prompt_ps1_exit_status_1)$(ps-color reset)\$(prompt_ps1_exit_status_2)$(ps-color bold green)\u@\H$(ps-color bold red) [\w]$(ps-color bold magenta) \d \t$(ps-color bold blue)\$(prompt_ps1_job_count \\j)$(ps-color bold cyan)\$(prompt_ps1_shlvl)$(ps-color bold yellow)\$(prompt_ps1_git_branch)\$(prompt_ps1_svn_branch)$(ps-color reset)\n\$ "
fi fi
PROMPT_COMMAND="_last_exit_status=\$?" PROMPT_COMMAND="_last_exit_status=\$?"