Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #11913

Re: Proposed Prompt Escapes

Path csiph.com!xmission!news.glorb.com!usenet.stanford.edu!not-for-mail
From isabella parakiss <izaberina@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: Proposed Prompt Escapes
Date Thu, 19 Nov 2015 05:49:46 +0100
Lines 29
Approved bug-bash@gnu.org
Message-ID <mailman.204.1447908589.31583.bug-bash@gnu.org> (permalink)
References <CANaoh6KA9Z3Uo_8qy-biaQx6MW1Z3h7DsC2uU-M=RTwrPPGBVA@mail.gmail.com> <1447798606.2074.5.camel@16bits.net> <CANaoh6LB3h9RciQgU0jh+GuJks0Px1=Bk+QJpd70xk9+8EbbWQ@mail.gmail.com> <1447899698.5874.4.camel@16bits.net>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-Trace usenet.stanford.edu 1447908590 9522 208.118.235.17 (19 Nov 2015 04:49:50 GMT)
X-Complaints-To action@cs.stanford.edu
Cc bug-bash@gnu.org
To Ángel González <angel@16bits.net>
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=bOg69/a7ybdcRyi+plfrFFnGfOprWS4MljCSHhpZGkc=; b=cRHHFi/u1EFowqaNU/Cz4Ia5aMb7lsDXGXo6mWwqD38Fep3zzIIKEXxjLn1/KcARfg tNrAO55bra9xfbly8otBKDUIwE9r/NFaOjZEe74gDva9Tj0vIyg3ItnjpjXm8+pP+fln b+eJ2e+p4hq/GkXDNeeE1haxSU6W03BWo4Aw/5qgTMWJWrFwFVx3vrFy6d9wTJeZRzdj qrhmvjp7YvBvpXTFqatk5MVFS0OghC5XOMwayCfxyErSN1fNpoPeDVOo41BI6dKPZ1dq nl6Vj7y6VO5vXPlPjVerjqczaO7UOsIJ5OQxNwnH4jVQhd82ag/fFPH7QeZbvgpNYoci 17SA==
X-Received by 10.107.7.84 with SMTP id 81mr6588378ioh.104.1447908586220; Wed, 18 Nov 2015 20:49:46 -0800 (PST)
In-Reply-To <1447899698.5874.4.camel@16bits.net>
X-detected-operating-system by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value).
X-Received-From 2607:f8b0:4001:c06::22d
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.14
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:11913

Show key headers only | View raw


On 11/19/15, Ángel González <angel@16bits.net> wrote:
> Dennis Williamson wrote:
>> Do you mean something like:
>>
>> PS1='$SECONDS '
>
> Not exactly. $SECONDS is the number of seconds since the shell was
> started. I am interested in the seconds elapsed by the last command.
>
> It is a hacky solution, but it could be done with:
>> PS1=''; PROMPT_COMMAND='printf "%s " $SECONDS; SECONDS=0'
>
>

You need to reset it right before the command is executed, PROMPT_COMMAND
is evaluated when the prompt is drawn, before you type your command.
A debug trap is better suited, but you have to make sure that it's only
executed once in a complex line.

Something along these lines should work:

PROMPT_COMMAND=debug_trap=0
trap '((!debug_trap++))&&SECONDS=0' debug
PS1='$SECONDS \$ '


---
xoxo iza

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Proposed Prompt Escapes isabella parakiss <izaberina@gmail.com> - 2015-11-19 05:49 +0100

csiph-web