| 1 | #!/bin/bash |
|---|
| 2 | # source this |
|---|
| 3 | function prompt_smile () { |
|---|
| 4 | local retval=$? |
|---|
| 5 | local red=196 |
|---|
| 6 | local yellow=226 |
|---|
| 7 | local green=46 |
|---|
| 8 | local darkgreen=28 |
|---|
| 9 | if [ $retval -eq 0 ]; then |
|---|
| 10 | color=$green |
|---|
| 11 | face=":-)" |
|---|
| 12 | elif [ $retval -eq 1 ]; then |
|---|
| 13 | color=$red |
|---|
| 14 | face=":-(" |
|---|
| 15 | elif [ $retval -eq 130 ]; then # INT |
|---|
| 16 | color=$yellow |
|---|
| 17 | face=":-|" |
|---|
| 18 | elif [ $retval -eq 132 ]; then # ILL |
|---|
| 19 | color=$darkgreen |
|---|
| 20 | face=":-&" |
|---|
| 21 | elif [ $retval -eq 137 ]; then # KILL |
|---|
| 22 | color=$red |
|---|
| 23 | face="X_X" |
|---|
| 24 | elif [ $retval -eq 139 ]; then # SEGV |
|---|
| 25 | color=$red |
|---|
| 26 | face=">_<" |
|---|
| 27 | elif [ $retval -eq 143 ]; then # TERM |
|---|
| 28 | color=$red |
|---|
| 29 | face="x_x" |
|---|
| 30 | else |
|---|
| 31 | color=$red |
|---|
| 32 | face="O_o" |
|---|
| 33 | fi |
|---|
| 34 | echo -e "\001$(tput setaf $color; tput bold)\002$face\001$(tput sgr0)\002" |
|---|
| 35 | return $retval # preserve the value of $? |
|---|
| 36 | } |
|---|
| 37 | PS1="$PS1\$(prompt_smile) " |
|---|