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

Re: Rewrite of zsh-newuser-install



On Fri, Feb 12, 2021 at 1:10 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Tue, Feb 9, 2021 at 10:58 PM Marlon Richert <marlon.richert@xxxxxxxxx> wrote:
> >
> [RE prompt truncation]
> >
> > Would using the actual ellipsis character be OK? Or do we have to
> > stick to ASCII?
>
> We probably have to aim at lower-capability terminals.  I suppose it
> might make sense to check [[ -o multibyte ]] and assume the terminal
> could handle the ellipsis if so, but how would multibyte become set?
> In the /etc/ files?

There is no straightforward way to check whether the terminal can
display a specific unicode character (e.g., the ellipsis). Even if
there was, and even if the check was simple, the benefits wouldn't be
high enough to justify the extra complexity in the default zshrc.

> I'm surprised we haven't heard from Roman about this, given the
> content of that reddit thread he linked back at the start of this.

I stopped commenting on this once I realized that my vision of what
the default zshrc should include is very different from everyone
else's here. In my view only the crucial things must be included.

How much is gained from defining PS2 and PS4? I think not much. I'd
remove them without second thoughts. Or consider history setup:

    HISTFILE=${ZDOTDIR:-${XDG_DATA_HOME:-$HOME/.local/share}/zsh}/history

    if [[ ! -d $HISTFILE:h ]]; then
      zmodload -F zsh/files b:zf_mkdir
      zf_mkdir -pm 0700 - $HISTFILE:h
    fi

    SAVEHIST=10000
    HISTSIZE=$(( 1.2 * SAVEHIST ))
    setopt EXTENDED_HISTORY
    setopt INC_APPEND_HISTORY_TIME
    setopt HIST_EXPIRE_DUPS_FIRST
    setopt HIST_IGNORE_DUPS

I'd replace it with this:

    HISTFILE=~/.zsh_history  # store command history in this file
    SAVEHIST=100000          # store at most this many commands in the file
    HISTSIZE=100000          # store at most this many commands in memory

Perhaps ${ZDOTDIR:-${XDG_DATA_HOME:-$HOME/.local/share}/zsh}/history
is better than ~/.zsh_history (I don't know if it is) but it's so much
more complex. Ditto for all the pet peeve options and arithmetic
expansions.

As far as prompt goes, I'd leave only PS1. No right prompt.

The only non-default option I would use is INTERACTIVE_COMMENTS. This
is important to allow people to copy-paste code from StackOverflow and
the like.

The amount of complexity brought in by the bindings is very high. If
the delete/home/end keys don't work, it's a disaster. On the other
hand, the binding for `redo` can be removed without anyone noticing or
complaining. As I mentioned earlier, I wouldn't use terminfo. It makes
the config more complex for little to no benefit. It also breaks
bindings when there is no terminfo definition for $TERM. This happens
when using a terminal with exotic terminfo (e.g., alacritty,
xterm-kitty, or tmux-256color) and connecting to another machine over
ssh.

In my opinion the default config shouldn't aim to provide the best
solution to anything: the best history setup, the best prompt, etc. It
should make zsh usable by someone who considers bash usable out of the
box (e.g., on Debian) but other than that be as simple and as short as
possible. Experienced zsh users are welcome to share more elaborate
and opinionated configs through other channels.

Roman.




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