| _show_last_exit_smilie() { | |||||
| # If the exit status of the last run command was a 0 (success), show a smile, otherwise a frown | |||||
| exit_status=$? | |||||
| if [[ "$exit_status" -ne 0 ]]; then | |||||
| echo "${NORMAL}[${RED}:(${NORMAL}]" | |||||
| else | |||||
| echo "${NORMAL}[${GREEN}:)${NORMAL}]" | |||||
| fi | |||||
| } | |||||
| # This function was modified from one found @ https://www.reddit.com/r/linux/comments/2uf5uu/this_is_my_bash_prompt_which_is_your_favorite/?st=jikgswh4&sh=371ba8bf | # This function was modified from one found @ https://www.reddit.com/r/linux/comments/2uf5uu/this_is_my_bash_prompt_which_is_your_favorite/?st=jikgswh4&sh=371ba8bf | ||||
| _git_status() { | |||||
| function _git_status() { | |||||
| local unknown untracked stash clean ahead behind staged dirty diverged | local unknown untracked stash clean ahead behind staged dirty diverged | ||||
| unknown=$BLUE | unknown=$BLUE | ||||
| untracked=$GREEN | untracked=$GREEN | ||||
| color=$diverged | color=$diverged | ||||
| branch="${branch}!" | branch="${branch}!" | ||||
| fi | fi | ||||
| echo -n "${NORMAL}|${color}${branch}${NORMAL}|" | |||||
| echo -n "${color}${branch}${NORMAL}|" | |||||
| fi | fi | ||||
| } | } | ||||
| set_prompt() { | set_prompt() { | ||||
| if [ $1 = yes ]; then | |||||
| echo -n "${debian_chroot:+($debian_chroot)}${GREEN}\u${NORMAL}[${BLUE}\w${NORMAL}]$(_show_last_exit_smilie)$(_git_status)\$ " | |||||
| local lec="$?" | |||||
| if [ $FORCE_COLOR_PROMPT = yes ]; then | |||||
| if [ $lec -ne 0 ]; then | |||||
| smilie="${RED}:(${NORMAL}" | |||||
| else | |||||
| smilie="${GREEN}:)${NORMAL}" | |||||
| fi | |||||
| PS1="${debian_chroot:+($debian_chroot)}${GREEN}\u${NORMAL}|${BLUE}\w${NORMAL}|${smilie}|$(_git_status)\$ " | |||||
| else | else | ||||
| echo -n "${debian_chroot:+($debian_chroot)}\u@\h:\w\$ " | |||||
| PS1="${debian_chroot:+($debian_chroot)}\u@\h:\w\$ " | |||||
| fi | fi | ||||
| } | |||||
| } | |||||
| PROMPT_COMMAND="set_prompt" |