| 1 | #!/bin/bash |
|---|
| 2 | # source this |
|---|
| 3 | function prompt_emoji () { |
|---|
| 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=$yellow |
|---|
| 11 | face=$'\360\237\230\200' # :D |
|---|
| 12 | elif [ $retval -eq 1 ]; then |
|---|
| 13 | color=$yellow |
|---|
| 14 | face=$'\360\237\230\246' # :( |
|---|
| 15 | elif [ $retval -eq 130 ]; then # INT |
|---|
| 16 | color=$yellow |
|---|
| 17 | face=$'\360\237\230\220' # :| |
|---|
| 18 | elif [ $retval -eq 132 ]; then # ILL |
|---|
| 19 | color=$darkgreen |
|---|
| 20 | #face=$'\360\237\244\242' # nauseated # get a rectangle in Konsole |
|---|
| 21 | face=$'\360\237\230\223' # cold sweat face |
|---|
| 22 | elif [ $retval -eq 137 ]; then # KILL |
|---|
| 23 | color=$yellow |
|---|
| 24 | face=$'\360\237\230\265' # x_x |
|---|
| 25 | elif [ $retval -eq 139 ]; then # SEGV |
|---|
| 26 | #color=$yellow |
|---|
| 27 | #face=$'\360\237\244\250' # Face with one eyebrow raised # get a rectangle in Konsole |
|---|
| 28 | color=$red |
|---|
| 29 | face=$'\360\237\230\240' # Angry face |
|---|
| 30 | elif [ $retval -eq 143 ]; then # TERM |
|---|
| 31 | color=$yellow |
|---|
| 32 | face=$'\360\237\230\243' # >_< |
|---|
| 33 | else |
|---|
| 34 | color=$yellow |
|---|
| 35 | face=$'\360\237\230\245' # ;( |
|---|
| 36 | fi |
|---|
| 37 | echo -e "\001$(tput setaf $color; tput bold)\002$face\001$(tput sgr0)\002" |
|---|
| 38 | return $retval # preserve the value of $? |
|---|
| 39 | } |
|---|
| 40 | PS1="$PS1\$(prompt_emoji) " |
|---|