3 ms·
On occasion I have posted something in debian-user, adding "but Greg will have a better approach". Then he shows up and offers a better approach. Thanks to Gr
by dsr_ 5y ago
On occasion I have posted something in debian-user, adding "but Greg will have a better approach".
Then he shows up and offers a better approach.
Thanks to Greg, my bashrc contains:
> stat=( )
> statcolor=("$Green" "$Red")
> ...
> PS1=...
> ${statcolor[!!$?]}\]${stat[!!$?]}$
Which, if it's not entirely clear, puts a green checkmark or a red x in my prompt depending on the error value of the last run commandline.
- marcosdumay 5y agoOh, a long time ago (but not so long as that) I got this line from a HN thread on bash tricks: export PS1="\h:\w \$(if [ \$? = 0 ]; then echo :\\\); else echo :\\\(; fi) \$ " It's a non-colored version of it, with a happy or sad smiley.