Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Rewrite of zsh-newuser-install



On Wed, Feb 10, 2021 at 4:30 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> > # $(( [#10] x )): cast x to int; COLUMNS: current line width of terminal
>
> Is there any advantage to computing this with PROMPT_SUBST versus, for
> example, reassigning PS1 with a new width in precmd?  Anyway if you're
> already allowing the dynamic parts to consume 40% of the terminal
> width I'm not sure it's worth the effort of making them dependent on
> that.  Just pick a width for %n@%M and a number of trailing components
> for %~.

When using $PROMPT_SUBST, the prompt will automatically adapt when I
resize my terminal window. It might not be necessary or the fastest
solution, but it certainly does increase the "cool" factor of the
prompt. ;)


> See previous comments in other messages, but if keeping this I'd put
> it in preexec instead.

I had it in preexec initially, but then, each time you press Enter on
an empty line or use a widget that doesn't trigger preexec, then the
timer keeps increasing, which looks stupid.


> > # m:{[:lower:]-}={[:upper:]_} does zsh-name -> ZSH_NAME
>
> Doesn't work for completing parameter names, e.g. $xdg-TAB just beeps.
> Is that an issue?

You're right; it doesn't work. That's weird. It seems to fail for
$parameter substitutions only. If I create a function FOO_BAR() {} and
type foo- , then Tab completes it just fine. Likewise, if I type xdg-
without the $, it works fine, too. Even when I set the matcher-list to
just 'm:{-}={_}', $XDG- still fails, but all the other cases succeed.
Feels like a bug to me.


> Speaking of that, heh, there should be a warning comment (?) or
> something that all of this expects to load in zsh native mode,
> otherwise those naked subscripts etc. will break.

Isn't safe to assume that new users are running in Zsh native mode? Or
why would anyone want to run .zshrc when not using Zsh? Or maybe I
misunderstand. What do you mean with "zsh native mode"? It feels to me
like such a comment is excessive. If you're going to unsetopt
PROMPT_PERCENT, then the prompt will break. Should we warn against
that, too?


> > () {
> >  local zcachedir=${ZDOTDIR:-${XDG_CACHE_HOME:-$HOME/.cache}/zsh}
>
> I wonder if it would be less potentially puzzling to use "function {"
> here instead of empty parens?

I don't think so. If you don't know how anonymous functions work in
Zsh in the first place, then merelymchanging the syntax is not going
to make it any clearer. I can add a comment to explain it or then
refactor it not use an anonymous function.




Messages sorted by: Reverse Date, Date, Thread, Author