Compare commits
No commits in common. "198242e1d573bf07c4f32a6437b8a7a1363a065b" and "0e954238773bc6fdd2540d1369f122174ffcdca0" have entirely different histories.
198242e1d5
...
0e95423877
|
@ -1,31 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
#
|
|
||||||
# Day 2 - Exit Code PS1 prompt
|
|
||||||
# "Pimp my prompt" with the return value of the last command.
|
|
||||||
# source this from ~/.bashrc or similar to modify PS1 to show the return value of previous command.
|
|
||||||
# Use the "demojify" command to restore your previous prompt after sourcing.
|
|
||||||
|
|
||||||
PS1OLD=$PS1
|
|
||||||
|
|
||||||
exitprompt ()
|
|
||||||
{
|
|
||||||
ERROR="$?"
|
|
||||||
if [ "$ERROR" -eq 0 ]
|
|
||||||
then
|
|
||||||
COLORCODE=32 # foreground green
|
|
||||||
EMOJI="🙂"
|
|
||||||
else
|
|
||||||
COLORCODE=31 # foreground red
|
|
||||||
EMOJI="🙁"
|
|
||||||
fi
|
|
||||||
echo -e "\e[${COLORCODE}m${ERROR} ${EMOJI} \e[0m"
|
|
||||||
}
|
|
||||||
|
|
||||||
demojify ()
|
|
||||||
{
|
|
||||||
PS1=$PS1OLD
|
|
||||||
}
|
|
||||||
|
|
||||||
PS1="\$(exitprompt)\n$PS1"
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Returns a non-zero exit code on purpose to test the day 2 error prompt.
|
|
||||||
|
|
||||||
exit 42
|
|
||||||
|
|
Reference in New Issue