zsh-workers
 help / color / mirror / code / Atom feed
From: Marlon Richert <marlon.richert@gmail.com>
To: Oliver Kiddle <opk@zsh.org>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Rewrite of zsh-newuser-install
Date: Sat, 13 Feb 2021 02:15:29 +0200	[thread overview]
Message-ID: <CAHLkEDtK5n56GjXKhR4VVCXcYUKjPzQb0zoj9E=BecsMsyWkFQ@mail.gmail.com> (raw)
In-Reply-To: <63124-1613172369.335393@kj4H.lfui.ly3G>

On Sat, Feb 13, 2021 at 1:26 AM Oliver Kiddle <opk@zsh.org> wrote:
> > # Use `exec zsh` to apply changes after editing this file.
>
> Not sure I'd recommend that because if you mistype "zsh", your shell+terminal
> disappears. And if they've broken .zshrc, that can leave them unable to log
> back in.

I got this tip from Roman. We've both seen new users get into all
kinds of trouble by repeatedly doing `source ~/.zshrc`.


> > HISTFILE=${ZDOTDIR:-${XDG_DATA_HOME:-$HOME/.local/share}/zsh}/history
>
> > # Create parent dir, if necessary.
> > if [[ ! -d $HISTFILE:h ]]; then
> >   zmodload -F zsh/files b:zf_mkdir
> >   zf_mkdir -pm 0700 - $HISTFILE:h
> > fi
>
> I'm not sure it helps new users to understand their new setup file if it needs
> this stuff. Should we just keep it simple at the expense of ignoring the XDG stuff.

Bart suggested we could instead, in zsh-newuser-install, ask the users
what they would actually prefer. I think that's reasonable. I put a
suggested text in my reply to him. I will start adding the new version
of zsh-newuser-install to the repo, too.


> > # %x<y<z%<<: if z is wider than x characters, then trim z from the left & insert y
>
> The trunction adds complexity that I'm not sure is needed. Many people want to
> know how to enable vcs_info. I'm not saying it should be included by
> default but perhaps in a comment.

I personally don't use truncation, because I use a multi-line prompt.
Others in this thread, though, insisted that new users should get a
single-line prompt. However, if you use an 80-column terminal that
often means you will run out of horizontal space quickly. I tried
truncating by leaving out segments, but I found the effect of that
undesirable: When the segments are short, it feels like information is
needlessly being hidden from you, whereas when the segments are long,
it still doesn't really save any space. Truncating to a fixed width
proved to be much more pleasant all-round, IMO. This way, it looked
more like the path was scrolling off-screen, which felt more natural.


> > zmodload -F zsh/zutil b:zstyle    # Load `zstyle` builtin.
>
> Is that really needed? I've never bothered.

I guess it depends on your Zsh installation. I thought I'd better be
safe than sorry. I already saw one error where add-zle-hook-widget
failed, because zsh/zle wasn't loaded yet.


> > # These are tried in order until one of them succeeds:
> > # _expand: expansion substitutions (See http://zsh.sourceforge.net/Doc/Release/Expansion.html)
> > # _complete: regular completions
> > # _history: words from history
> > # _correct: spelling corrections
> > # _ignored: any completions that have been ignored so far
> > zstyle ':completion:*' completer _expand _complete _history _correct _ignored
>
> These seem reasonable choices. _extensions wouldn't cause any unpleasant
> surprises for a new user but it does need to come first.

_extensions feels rather useless when you can get the same effect
through matchers, but without requiring the leading *.


> > # m:{[:lower:]-}={[:upper:]_} does foo-bar -> FOO_BAR
> but not vice versa.

Yes, that is intentional. :)


> > # r:|?=** does fbr -> foo-bar and bar -> foo-bar
> > zstyle ':completion:*:complete:*' matcher-list \
> >   'r:|[.]=** r:?|[-_]=** l:?|=[-_] m:{[:lower:]-}={[:upper:]_}' \
> >   'r:|?=** m:{[:lower:]}={[:upper:]}'
>
> I'd be significantly more conservative on these. They really can cause
> surprises for new users and break some things completely like trying to force
> the type of listed matches with punctuation prefixes.

I've used something like this for quite a while now. I'm unsure what
kind of breakage you are referring to.


> I mostly use generous matchers with more specific contexts.
> To give one example, the following helps when suspended jobs are all
> man, less or vim and I want to select on the argument:
> zstyle ':completion:*:(-command-|[fb]g):*:jobs' matcher 'l:%|=*'

I'm hesitant to do this kind of tweaking. I'd rather apply the Pareto
principle and have a generic solution that's good enough for most
cases. If there's anything specific that needs to be done for certain
completion, then it should happen in the completion function IMO.


> > # For options only, add - -> + for each item in the list above.
> > zstyle ':completion:*:options' matcher 'm:{-}={+}'
>
> Isn't the more limited 'b:-=+' sufficient here?

Perhaps, if you can explain to me what it does. :)


> > # Show and insert `man` sections.
> > zstyle ':completion:*' insert-sections yes
>
> I wouldn't bother for section 1:
>   zstyle ':completion:*:manuals.(^1*)' insert-sections true
>
> Not only because it is mostly redundant but it is easier to simplify that to
> all sections than to do the reverse.

Again, I don't see any real gain to adding that. It works fine without.


> I'd be inclined to bind Ctrl-Z to undo. Forget Emacs and Vi - Ctrl-Z is what
> the rest of the world uses for undo. That doesn't disable anything else and too
> few people know the shell has an undo. It's invaluable with completion,
> especially with approximate completion or the fuzzier matching controls such as
> r:|?=**.

Sure. And then Ctrl-Y to redo? Seems reasonable to me.


> > setopt GLOB_STAR_SHORT      # Use `**` for recursive globbing; `***` to include symlinks, too.
>
> Need to say 'without a trailing "/"' **/ is already recursive globbing
> and you don't need this option to enable it.
>
> The comment confused me but like Bart I don't use the option but found
> myself wondering whether I should.

I personally find it quite useful, especially when combined with the
_expand completer. :)


> > typeset -gU PATH path FPATH fpath CDPATH cdpath MANPATH manpath
>
> These are tied, no need to list both forms.

The documentation of typeset -U says otherwise, though:

http://zsh.sourceforge.net/Doc/Release/Shell-Builtin-Commands.html#index-typeset
> -U
> For arrays (but not for associative arrays), keep only the first occurrence of each duplicated value. This may also be set for tied parameters (see -T) or colon-separated special parameters like PATH or FIGNORE, etc. Note the flag takes effect on assignment, and the type of the variable being assigned to is determinative; for variables with shared values it is therefore recommended to set the flag for all interfaces, e.g. ‘typeset -U PATH path’.

Should that text be changed?


> The -g adds nothing either outside of a function.

I know, but I felt like it's good to be consistent, in case the user
ever puts in a function.


Thanks for your input!


  reply	other threads:[~2021-02-13  0:16 UTC|newest]

Thread overview: 117+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-06 20:03 Marlon Richert
     [not found] ` <0102017778f35f33-a962e4d3-83e9-4d3b-a0d7-45701bb40b11-000000@eu-west-1.amazonses.com>
2021-02-06 20:19   ` Marlon Richert
2021-02-06 20:33     ` Lawrence Velázquez
2021-02-06 21:54       ` Bart Schaefer
2021-02-07 13:41       ` Marlon Richert
2021-02-07 13:51         ` Roman Perepelitsa
2021-02-07 17:10           ` Marlon Richert
2021-02-07 17:28             ` Marlon Richert
2021-02-07 20:20               ` Bart Schaefer
2021-02-07 21:06             ` dana
2021-02-07 21:15               ` Marlon Richert
2021-02-08 21:57                 ` Marlon Richert
2021-02-08 23:33                   ` Lawrence Velázquez
2021-02-09  1:42                   ` Bart Schaefer
2021-02-09  2:00                     ` Bart Schaefer
2021-02-09  8:18                       ` Marlon Richert
2021-02-09 23:09                         ` Bart Schaefer
2021-02-09  8:17                     ` Marlon Richert
2021-02-09  8:29                       ` Roman Perepelitsa
2021-02-09 23:16                         ` Bart Schaefer
2021-02-12  0:09                       ` Bart Schaefer
2021-02-12  5:58                         ` Marlon Richert
2021-02-09  4:51                   ` dana
2021-02-09  6:00                     ` Bart Schaefer
2021-02-09  7:30                       ` dana
2021-02-09  7:34                         ` dana
2021-02-09  9:55                       ` Marlon Richert
2021-02-09 10:01                         ` Roman Perepelitsa
2021-02-09 10:04                           ` Marlon Richert
2021-02-09 10:56                             ` dana
2021-02-09 11:14                               ` Roman Perepelitsa
2021-02-09 11:39                               ` Marlon Richert
2021-02-09 17:21                                 ` dana
2021-02-09 21:01                                   ` Marlon Richert
2021-02-09 21:41                                     ` Marlon Richert
2021-02-09 23:15                                       ` dana
2021-02-10  0:02                                         ` Bart Schaefer
2021-02-10  7:02                                           ` Marlon Richert
2021-02-10  6:57                                         ` Marlon Richert
2021-02-12  0:10                                           ` Bart Schaefer
2021-02-12  5:59                                             ` Roman Perepelitsa
2021-02-13  0:23                                               ` dana
2021-02-10  2:30                                       ` Bart Schaefer
2021-02-10  7:44                                         ` Marlon Richert
2021-02-10 20:27                                           ` Marlon Richert
2021-02-11  8:30                                             ` Bart Schaefer
2021-02-11 21:11                                               ` Marlon Richert
2021-02-11 22:57                                                 ` Bart Schaefer
2021-02-12  5:49                                                   ` Marlon Richert
2021-02-12  5:47                                               ` Marlon Richert
2021-02-12 23:43                                                 ` Oliver Kiddle
2021-02-13  1:11                                                 ` Bart Schaefer
2021-02-12 23:26                                             ` Oliver Kiddle
2021-02-13  0:15                                               ` Marlon Richert [this message]
2021-02-13  1:33                                                 ` Bart Schaefer
2021-02-13  1:36                                                 ` Oliver Kiddle
2021-02-13  2:53                                                   ` Bart Schaefer
2021-02-13 10:26                                                   ` Marlon Richert
2021-02-13 22:53                                                     ` Marlon Richert
2021-02-14  0:34                                                       ` Bart Schaefer
2021-02-14  8:12                                                         ` Marlon Richert
2021-02-13 22:56                                                     ` Bart Schaefer
2021-02-14  8:01                                                       ` Marlon Richert
2021-02-19 21:38                                                         ` Marlon Richert
2021-02-20  0:30                                                           ` dana
2021-02-20  8:18                                                             ` Marlon Richert
2021-02-20 18:57                                                               ` Bart Schaefer
2021-02-21 19:24                                                                 ` Marlon Richert
2021-02-24 22:15                                                               ` dana
2021-02-25  8:05                                                                 ` Daniel Shahaf
2021-02-25 16:58                                                                   ` dana
2021-02-26 22:31                                                                   ` Marlon Richert
2021-02-27 13:21                                                                     ` Daniel Shahaf
2021-02-27 13:46                                                                       ` Daniel Shahaf
2021-03-19 22:12                                                                       ` Marlon Richert
2021-03-24 13:45                                                                         ` gi1242+zsh
2021-03-24 14:16                                                                           ` Paul
2021-03-24 17:44                                                                           ` Bart Schaefer
2021-03-24 20:38                                                                             ` Marlon Richert
2021-03-25  3:36                                                                         ` Paul
2021-04-05 18:16                                                                         ` Daniel Shahaf
2021-04-05 18:52                                                                           ` Sorting of <-> (was Re: Rewrite of zsh-newuser-install) Bart Schaefer
2021-04-05 21:31                                                                           ` Rewrite of zsh-newuser-install gammafunction
2021-04-07 14:45                                                                           ` Marlon
2021-04-09 16:49                                                                             ` Marlon
2021-04-09 23:14                                                                               ` Daniel Shahaf
2021-04-10  1:17                                                                                 ` Oliver Kiddle
2021-04-07 18:17                                                                           ` Mikael Magnusson
2021-04-07 18:56                                                                             ` Daniel Shahaf
2021-03-24 10:00                                                                       ` Marlon Richert
2021-03-25  1:15                                                                         ` Daniel Shahaf
2021-04-05 14:00                                                                           ` Marlon Richert
2021-04-05 18:36                                                                             ` Daniel Shahaf
2021-04-05 19:22                                                                               ` Daniel Shahaf
2021-02-22  3:54                                                           ` Paul
2021-02-22  8:14                                                             ` Marlon Richert
2021-02-22 16:31                                                               ` Bug in compdescribe with matcher 'b:-=+' Bart Schaefer
2021-06-14  8:28                                                                 ` Marlon Richert
2021-08-12 12:03                                                                   ` Marlon Richert
2021-08-12 16:15                                                                     ` Bart Schaefer
2021-02-19 21:34                                                       ` Rewrite of zsh-newuser-install Marlon Richert
2021-02-13  1:28                                               ` Bart Schaefer
2021-02-13  1:34                                                 ` Bart Schaefer
2021-04-22 13:57                                               ` Marlon Richert
2021-02-09 23:05                                 ` Bart Schaefer
2021-02-09  9:44                     ` Marlon Richert
2021-02-09 18:13                       ` Greg Klanderman
2021-02-08  9:21               ` Peter Stephenson
2021-02-08  6:35             ` Daniel Shahaf
2021-02-08  8:44               ` Marlon Richert
2021-02-08  8:46                 ` Marlon Richert
2021-02-08 10:32                   ` Daniel Shahaf
2021-02-08 17:44                     ` Marlon Richert
2021-02-08 20:47                       ` Bart Schaefer
2021-02-09 21:44             ` Eric Cook
2021-02-09 22:34               ` Bart Schaefer
2021-02-07 20:22         ` Bart Schaefer

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='CAHLkEDtK5n56GjXKhR4VVCXcYUKjPzQb0zoj9E=BecsMsyWkFQ@mail.gmail.com' \
    --to=marlon.richert@gmail.com \
    --cc=opk@zsh.org \
    --cc=zsh-workers@zsh.org \
    /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).