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


Groups > linux.debian.user > #228018

Re: Zoom.

From Dan Ritter <dsr@randomstring.org>
Newsgroups linux.debian.user
Subject Re: Zoom.
Date 2020-10-20 14:10 +0200
Message-ID <B1YCJ-tf-5@gated-at.bofh.it> (permalink)
References (1 earlier) <B15Gh-N6-1@gated-at.bofh.it> <B1KzN-lB-29@gated-at.bofh.it> <B1Pzs-3kQ-1@gated-at.bofh.it> <B1XdE-7VW-7@gated-at.bofh.it> <B1Y9I-8vu-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Greg Wooledge wrote: 
> On Tue, Oct 20, 2020 at 06:36:15AM -0400, Dan Ritter wrote:
> > I have this in my PS1 definition:
> > 
> > \$(if [[ \$? == 0 ]]; then echo \"+\"; else echo \"-\"; fi)\
> > 
> > Which has the effect of telling me the rough exit status of the
> > last command in my prompt. 
> 
> The weird backslashing tells me you're defining PS1 with double quotes
> instead of single quotes, which is weird, and probably indicates that
> you're doing even worse things, like dynamically generating pieces of
> your PS1... I've seen things... things that no man should see....


Regain some SAN points: none of the rest of it is weird. 

Two lines. First line is a colorized \u@\h:\w\, the second line
is the exit status and \$  


> Anyway, in addition to the weird quoting and possible abominations
> unrevealed, your command substitution forks.  Every time the prompt
> is drawn, a new process is forked, just to do that simple "if" check.
> 
> The standard workaround for that is to use an array variable with the
> two possible outcomes, and a bit of arithmetic.
> 
> unicorn:~$ green=$(tput setaf 2) red=$(tput setaf 1) normal=$(tput sgr0)
> unicorn:~$ status=(+ -) statcolor=("$green" "$red")
> unicorn:~$ PS1='\[${statcolor[!!$?]}\]${status[!!$?]}\[$normal\] \h:\w\$ '
> + unicorn:~$ true
> + unicorn:~$ false
> - unicorn:~$ true
> + unicorn:~$ 

Thanks, When I get around to redoing my PS1, I'll use that and
fix the quoting.

-dsr-

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Zoom. peter@easthope.ca - 2020-10-17 23:10 +0200
  Re: Zoom. Charles Curley <charlescurley@charlescurley.com> - 2020-10-17 23:40 +0200
  Re: Zoom. Peter Ehlert <peter@sdi-baja.com> - 2020-10-18 00:10 +0200
  Re: Zoom. Carl Fink <carlf@panix.com> - 2020-10-18 01:00 +0200
    Re: Zoom. conover@rahul.net (John Conover) - 2020-10-18 01:40 +0200
  Re: Zoom. David <bouncingcats@gmail.com> - 2020-10-18 01:50 +0200
    Re: Zoom. riveravaldez <riveravaldezmail@gmail.com> - 2020-10-18 05:10 +0200
    Re: Zoom. Tom Dial <tddial@comcast.net> - 2020-10-18 09:20 +0200
  Re: Zoom. Bob McGowan <ramjr0915@gmail.com> - 2020-10-18 03:30 +0200
    Re: Zoom. peter@easthope.ca - 2020-10-19 23:10 +0200
      Re: Zoom. Michael Stone <mstone@debian.org> - 2020-10-19 23:10 +0200
        Re: Zoom. peter@easthope.ca - 2020-10-22 15:30 +0200
          Re: Zoom. Michael Stone <mstone@debian.org> - 2020-10-22 16:40 +0200
      Re: Zoom. John Crawley <john@bunsenlabs.org> - 2020-10-20 04:30 +0200
        Re: Zoom. Dan Ritter <dsr@randomstring.org> - 2020-10-20 12:40 +0200
          Re: Zoom. Nicolas George <george@nsup.org> - 2020-10-20 13:20 +0200
          Re: Zoom. Greg Wooledge <wooledg@eeg.ccf.org> - 2020-10-20 13:40 +0200
            Re: Zoom. Dan Ritter <dsr@randomstring.org> - 2020-10-20 14:10 +0200
            Re: shells (was Re: Zoom.) rhkramer@gmail.com - 2020-10-20 17:00 +0200
              Re: shells (was Re: Zoom.) Nicolas George <george@nsup.org> - 2020-10-20 17:00 +0200
              Re: shells (was Re: Zoom.) Tony van der Hoff <lists@vanderhoff.org> - 2020-10-20 17:40 +0200
  Re: Zoom. A_Man_Without_Clue <love.chaser@gmail.com> - 2020-10-18 05:20 +0200
  Re: Zoom. Stefan Monnier <monnier@iro.umontreal.ca> - 2020-10-18 17:20 +0200
    Re: Zoom. Sven Hartge <sven@svenhartge.de> - 2020-10-18 17:50 +0200
      Re: Zoom. <tomas@tuxteam.de> - 2020-10-19 09:30 +0200
        Re: Zoom. Sven Hartge <sven@svenhartge.de> - 2020-10-19 09:40 +0200
          Re: Zoom. David Wright <deblis@lionunicorn.co.uk> - 2020-10-19 17:10 +0200
          Re: Zoom. Stefan Monnier <monnier@iro.umontreal.ca> - 2020-10-19 17:30 +0200
            Re: Zoom. <tomas@tuxteam.de> - 2020-10-19 17:40 +0200
            Re: Zoom. Stefan Monnier <monnier@iro.umontreal.ca> - 2020-10-19 18:00 +0200
          Re: Zoom. Stefan Monnier <monnier@iro.umontreal.ca> - 2020-10-19 17:40 +0200
        Re: Zoom. "Thomas Schmitt" <scdbackup@gmx.net> - 2020-10-19 10:00 +0200
    Re: Zoom. peter@easthope.ca - 2020-10-20 03:20 +0200
      Re: Zoom. <tomas@tuxteam.de> - 2020-10-20 10:10 +0200
    Re: Zoom. peter@easthope.ca - 2020-10-20 03:30 +0200
    Server for Jitsi; was: Zoom. peter@easthope.ca - 2020-10-22 20:20 +0200
      Re: Server for Jitsi; was: Zoom. Dan Ritter <dsr@randomstring.org> - 2020-10-22 20:40 +0200
      Re: Server for Jitsi; was: Zoom. "der.hans" <deb-user@LuftHans.com> - 2020-10-22 21:00 +0200
      Re: Server for Jitsi; was: Zoom. Stefan Monnier <monnier@iro.umontreal.ca> - 2020-10-23 01:40 +0200

csiph-web