$PROMPT_COMMAND (WAS: Re: Using $PROMPT_COMMAND to beep depending on success/failure)

Lars Bjørndal lars at lamasti.net
Fri Apr 22 21:09:23 UTC 2016


On Wed, Apr 20, 2016 at 01:41:11PM -0500, Tim Chase wrote:
> Stumbled on this one today thanks to @climagic on Twitter.  If you
> want to have your machine give you one tone if the previous command
> succeeded (had an exit-status of 0) and a different tone if the
> previous command failed (had a non-zero exit status), you can put the
> following one-liner in your .bashrc file:
> 
> PROMPT_COMMAND='[ "$?" == 0 ] && play -qn synth sin F3 trim 0 0 0.1
> fade 0 0.1 0.05 vol 0.2 || play -qn synth square F4 trim 0 0.1 fade 0
> 0.1 0.05'

Do any of you know of a way to get a number as the first cell(s)
in the prompt indicating the error code of the previous command? E.g.

1[user at host ~]#

if something gets wrong? If zero, I'd like to get no number output.
I think that could be convenient when using braille.

Thanks and regards, Lars




More information about the Blinux-list mailing list