$PROMPT_COMMAND (WAS: Re: Using $PROMPT_COMMAND to beep depending on success/failure)
jdashiel at panix.com
Mon Apr 25 00:05:05 UTC 2016
Test $?, or key in a command name you know isn't on your system and
after command not found returns type echo $? then hit enter. You'll get
the error code back that way.
On Fri, 22 Apr 2016, Lars Bj?rndal wrote:
> Date: Fri, 22 Apr 2016 17:09:23
> From: Lars Bj?rndal <lars at lamasti.net>
> Reply-To: Linux for blind general discussion <blinux-list at redhat.com>
> To: Linux for blind general discussion <blinux-list at redhat.com>
> Subject: $PROMPT_COMMAND (WAS: Re: Using $PROMPT_COMMAND to beep depending on
> 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
> Blinux-list mailing list
> Blinux-list at redhat.com
More information about the Blinux-list