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

Lars Bjørndal <[email protected]>
Newsgroups gmane.linux.redhat.blinux.general
Message-ID <[email protected]>
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@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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.