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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On 4/22/2016 2:09 PM, Lars wrote:
> 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?

Yes, just include "$?" in your $PS1 variable.  I have something like:

  export PS1='{$?}\u@\h:\w\$ '

in my ~/.bashrc to give me a prompt like

  {0}tim@netbook:/etc$

where the "{0}" at the beginning shows the exit/error code from the
previously-run program.

I include the username ("\u"), short hostname ("\h"), and working
directory ("\w") mostly because I manage a number of machines, so it
helps me make sure I'm not issuing commands on some remote box I
admin.

-tim



_______________________________________________
Blinux-list mailing list
Blinux-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/blinux-list



[Index of Archives]     [Linux Speakup]     [Fedora]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]