help-bash
[Top][All Lists]
Advanced

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

Re: how to exclude results from PS0\1 \ PROMPT_COMMAND


From: Greg Wooledge
Subject: Re: how to exclude results from PS0\1 \ PROMPT_COMMAND
Date: Fri, 12 Mar 2021 11:08:21 -0500

On Fri, Mar 12, 2021 at 03:07:04PM +0100, ikhxcsz7y xmbott wrote:
> i just observed PS0 gets printed by every command also in PROMPT_COMMAND so
> i wondered how to exclude such

Exclude such... what?

Anyway, the obvious reason PS0 exists is so that you can print "I am
running foobar now" in your terminal's title bar or status line or
whatever.

For example:

title() { local IFS=' '; printf '\e]2;%s\a' "$*"; }
PS0='\[\e]2;$(history 1)\a\]'
PROMPT_COMMAND='title bash'

(I think we're missing some PROMPTING escape sequences containing the
current command name, and the full current command.  More on this later.)

> -- cut -- sorry its a bit off the project but i wanted to answer you, sadly
> i cant write exactly whaht i mean into words here - im sorry

Why not?

> in short
> a) exclude cmds from display system
> a.2) possibly by having a list of patterns to excllude then cutting those
> off of $BASH_COMMAND
> a.2.1) then on PS* use ${var:+format here}

The last thing, a.2.1, is a very bad sign.  It tells me that you're
designing this thing only so you can use this syntax feature that you're
currently in love with.  You have a "solution" and you're looking for a
"problem" so you can use it.

If we ignore that... what is this "display system" you mention in a?

For a.2, what is BASH_COMMAND?  Oh, that's a thing... let me read the
section on that in the manual.

OK, now I know why I've never heard of BASH_COMMAND before, and why it's
not mentioned in the PROMPTING section.  It's because it's useless.  It
contains the PREVIOUS command, not the CURRENT command.

If I set PS0='\[\e]2;$BASH_COMMAND\a\]' it keeps showing the previous
command in the title bar, rather than the current command.  So, another
feature that we can ignore forever.

That brings us back to "what are you doing"?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]