zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh-Workers <zsh-workers@sunsite.dk>
Subject: Re: readability (was: Re: prompt color pbg ,pfg,pbg_bold,pfg_bold in colors function?)
Date: Sat, 19 Aug 2006 11:39:25 -0700	[thread overview]
Message-ID: <060819113925.ZM28549@torch.brasslantern.com> (raw)
In-Reply-To: <20060819064335.GA13552@finlandia.home.infodrom.org>

On Aug 19,  8:43am, Matthias Kopfermann wrote:
}
} > Another reason I resisted this is that it leads to PS1 values that
} > contain lots more %{ %} pairs than are often necessary.  E.g., for a
} > two-line prompt, you can often put the entire first line in a single
} > pair of %{ ... %}.
} 
} if one only uses one color , you mean?

No; if you have a two-line prompt.  The first line of the prompt makes
no difference at all to the length of the line where zle will be editing,
so you can do

PS1=$'%{whole first line with all sorts of color changes\n%}nextline% '

In fact now that I think of it zle may be smart enough to ignore all
the stuff before the newline, in which case you don't need the %{ %}
at all on that line.

} perhaps i was mistaken to think that every escape code needs
} needs these %{ %} around it.
} so i thought it really had to be done  with any new one.

Think of it in terms of cursor motion.  You need %{ when the cursor
stops moving and %} when it starts again, and in between you can do
anything you like (including sending the cursor off to some other
part of the screen, as long as you bring it back to the original spot
again before closing the braces).  You also need %{ and %} only as
they affect the same screen line where the prompt finally finishes,
because zle only cares about horizontal position, not vertical.

} The biggest problem in zsh functions is readability

You mean in cryptic sytax for parameter expansions and format strings.
Yes, in many ways shells are a throwback to the days when the number
of bytes or keystrokes used made a large difference, and interpreters
could not compile and call user-defined functions for things like
prompts and string manipulation.  Also the requirement for using the
unix stdin/stdout pipe model for text manipulation made it much more
efficient to build things into the shell syntax that would have been
better handled externally.


  reply	other threads:[~2006-08-19 18:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-18 10:26 prompt color pbg ,pfg,pbg_bold,pfg_bold in colors function? Matthias Kopfermann
2006-08-18 13:08 ` Frank Terbeck
2006-08-18 18:03   ` Bart Schaefer
2006-08-19  6:43     ` readability (was: Re: prompt color pbg ,pfg,pbg_bold,pfg_bold in colors function?) Matthias Kopfermann
2006-08-19 18:39       ` Bart Schaefer [this message]
2006-08-20  6:56         ` Matthias Kopfermann
2006-08-20 17:33           ` Bart Schaefer
2006-08-20 18:47             ` Matthias Kopfermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=060819113925.ZM28549@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).