bash_aliases: split up PS1 into multiple components
remove date/time from prompt move git/svn status to second line
This commit is contained in:
parent
d3d9a98248
commit
eec46ef9b2
28
bash_aliases
28
bash_aliases
@ -90,7 +90,7 @@ function prompt_ps1_git_branch()
|
|||||||
if [[ "$git_branch_out_line" =~ $re2 ]]; then
|
if [[ "$git_branch_out_line" =~ $re2 ]]; then
|
||||||
current_branch="$current_branch: ${BASH_REMATCH[1]}"
|
current_branch="$current_branch: ${BASH_REMATCH[1]}"
|
||||||
fi
|
fi
|
||||||
echo " ${current_branch}${ahead_behind}"
|
echo "${current_branch}${ahead_behind} "
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done <<< "$git_branch_out"
|
done <<< "$git_branch_out"
|
||||||
@ -104,18 +104,34 @@ function prompt_ps1_svn_branch()
|
|||||||
re_branch="\\<(tags|branches)/([^/]*)\\>"
|
re_branch="\\<(tags|branches)/([^/]*)\\>"
|
||||||
re_trunk="\\<trunk\\>"
|
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
|
||||||
echo " ${BASH_REMATCH[0]}"
|
echo "${BASH_REMATCH[0]} "
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "${USER}" == "root" ]]; then
|
# exit status
|
||||||
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\$ "
|
PS1="$(ps-color bold white on-red)\$(prompt_ps1_exit_status_1)$(ps-color reset)\$(prompt_ps1_exit_status_2)"
|
||||||
|
# user name and host name
|
||||||
|
if [ "$USER" = "root" ]; then
|
||||||
|
PS1="${PS1}$(ps-color bold red)"
|
||||||
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 cyan) \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\$ "
|
PS1="${PS1}$(ps-color bold magenta)"
|
||||||
fi
|
fi
|
||||||
|
PS1="${PS1}\u@\H"
|
||||||
|
# working directory
|
||||||
|
PS1="${PS1} $(ps-color bold cyan)\w"
|
||||||
|
# job count
|
||||||
|
PS1="${PS1}$(ps-color bold blue)\$(prompt_ps1_job_count \\j)"
|
||||||
|
# shell level
|
||||||
|
PS1="${PS1}$(ps-color bold green)\$(prompt_ps1_shlvl)"
|
||||||
|
# \n
|
||||||
|
PS1="${PS1}$(ps-color reset)\n"
|
||||||
|
# git/svn info
|
||||||
|
PS1="${PS1}$(ps-color bold yellow)\$(prompt_ps1_git_branch)\$(prompt_ps1_svn_branch)"
|
||||||
|
# dollar
|
||||||
|
PS1="${PS1}$(ps-color reset)\$ "
|
||||||
|
|
||||||
PROMPT_COMMAND="_last_exit_status=\$?"
|
PROMPT_COMMAND="_last_exit_status=\$?"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user