| @@ -1,17 +1,6 @@ | |||
| _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 | |||
| _git_status() { | |||
| function _git_status() { | |||
| local unknown untracked stash clean ahead behind staged dirty diverged | |||
| unknown=$BLUE | |||
| untracked=$GREEN | |||
| @@ -60,15 +49,23 @@ _git_status() { | |||
| color=$diverged | |||
| branch="${branch}!" | |||
| fi | |||
| echo -n "${NORMAL}|${color}${branch}${NORMAL}|" | |||
| echo -n "${color}${branch}${NORMAL}|" | |||
| fi | |||
| } | |||
| 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 | |||
| echo -n "${debian_chroot:+($debian_chroot)}\u@\h:\w\$ " | |||
| PS1="${debian_chroot:+($debian_chroot)}\u@\h:\w\$ " | |||
| fi | |||
| } | |||
| } | |||
| PROMPT_COMMAND="set_prompt" | |||