Path: csiph.com!xmission!news.glorb.com!usenet.stanford.edu!not-for-mail From: isabella parakiss 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: References: <1447798606.2074.5.camel@16bits.net> <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: =?UTF-8?B?w4FuZ2VsIEdvbnrDoWxleg==?= 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:11913 On 11/19/15, =C3=81ngel Gonz=C3=A1lez wrote: > Dennis Williamson wrote: >> Do you mean something like: >> >> PS1=3D'$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=3D''; PROMPT_COMMAND=3D'printf "%s " $SECONDS; SECONDS=3D0' > > 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=3Ddebug_trap=3D0 trap '((!debug_trap++))&&SECONDS=3D0' debug PS1=3D'$SECONDS \$ ' --- xoxo iza