Change default shell from bash to zsh by default?

Merged, thanks!

sudo apt-get-reset desktop-config-dist

Now I keep getting this prompt:

This is the Z Shell configuration function for new users,
zsh-newuser-install.

But it’s weird because otherwise all functionality (colors, command completion) are functional as expected.

Any idea?

For testing, please make sure you don’t have a local ~/.zshrc file. That would avoid reproduction of this issue.

ls ~/.zshrc

At which moment do you get this prompt?

I deleted ~/.zshrc and ran zsh but not warning appeared.

Edit: on one machine I could reproduce.

1 Like

Will disable the zsh-newuser module as per man:

WHEN THE SHELL STARTS
       When it starts, the shell reads commands from various files.   These  can  be  created  or
       edited to customize the shell.  See the section Startup/Shutdown Files in zsh(1).

       If  no personal initialization files exist for the current user, a function is run to help
       you change some of the most common settings.  It won't appear if  your  administrator  has
       disabled  the  zsh/newuser  module.  The function is designed to be self-explanatory.  You
       can run it by hand with `autoload -Uz zsh-newuser-install; zsh-newuser-install  -f'.   See
       also the section User Configuration Functions in zshcontrib(1).
1 Like
THE ZSH/NEWUSER MODULE
       The  zsh/newuser  module  is loaded at boot if it is available, the RCS option is set, and
       the PRIVILEGED option is not set (all three are true by default).  This takes place  imme‐
       diately after commands in the global zshenv file (typically /etc/zsh/zshenv), if any, have
       been executed.  If the module is not available it is silently ignored by  the  shell;  the
       module may safely be removed from $MODULE_PATH by the administrator if it is not required.

       On  loading,  the  module tests if any of the start-up files .zshenv, .zprofile, .zshrc or
       .zlogin exist in the directory given by the environment variable ZDOTDIR,  or  the  user's
       home  directory  if  that is not set.  The test is not performed and the module halts pro‐
       cessing if the shell was in an emulation mode (i.e. had been invoked as some  other  shell
       than zsh).

       If none of the start-up files were found, the module then looks for the file newuser first
       in a sitewide directory, usually the parent directory of the site-functions directory, and
       if that is not found the module searches in a version-specific directory, usually the par‐
       ent of the functions directory containing version-specific functions.  (These  directories
       can  be  configured  when  zsh  is  built  using the --enable-site-scriptdir=dir and --en‐
       able-scriptdir=dir flags to configure, respectively; the defaults are prefix/share/zsh and
       prefix/share/zsh/$ZSH_VERSION where the default prefix is /usr/local.)

       If  the  file  newuser is found, it is then sourced in the same manner as a start-up file.
       The file is expected to contain code to install start-up files for the user,  however  any
       valid shell code will be executed.

       The zsh/newuser module is then unconditionally unloaded.

       Note  that  it is possible to achieve exactly the same effect as the zsh/newuser module by
       adding code to /etc/zsh/zshenv.  The module exists simply to allow the shell to  make  ar‐
       rangements for new users without the need for intervention by package maintainers and sys‐
       tem administrators.

       The script supplied with the module invokes the shell function zsh-newuser-install.   This
       may  be  invoked  directly  by the user even if the zsh/newuser module is disabled.  Note,
       however, that if the module is not installed the function will not  be  installed  either.
       The function is documented in the section User Configuration Functions in zshcontrib(1).

still searching how to disable a zsh module

1 Like

Trying to avoid this debian - Disable the configuration tool in Zsh - Unix & Linux Stack Exchange

changing /etc/zsh/zshenv because the answer is not good at all, it will clear the function and the user won’t be able to use it if they want to run manually.

1 Like

https://www.zsh.org/mla/users/2007/msg00398.html

https://www.zsh.org/mla/users/2007/msg00400.html

Upstream did not give a good response, just simply remote the file they said, but does not fix pkg mngmt problems after package is reinstalled, will require a patch on /usr/share/zsh/5.8/scripts/newuser, but the bad thing is that the path is by version and this could soon lead to an error for Zsh 5.9.

1 Like

Can we simply touch ~/.zshrc again?

1 Like

File ~/.zshrc seems the best solution indeed after checking your research on this issue.
Not sure we can run touch ~/.zshrc from debian postinst script. Would be touch /home/user/.zshrc. But the APT sandbox (probably) might block it similarly to:

Would could add .zshrc' to /etc/skel`. I.e.

/etc/skel/.zshrc

A skel based solution would also be compatible with multi-user setups.

That would work for new builds. So zsh could be enabled by default in the next point release.

As for changing existing users default shell from bash to zsh, I am not sure that’s important or if we even should do that. If so, we’d need to add the csh and touch command here: legacy-dist/usr/libexec/legacy-dist/fixes at master · Kicksecure/legacy-dist · GitHub (as it won’t work from APT).

I think it is /home/$USER/.zshrc

/etc/skel/.zshrc created empty

APT / deb postinst scripts doesn’t have a $USER variable.

Great, merged!

Small issue…

functional in bash:

git verify-commit 16.0.8.2-stable^{commit}

broken in zsh:

git verify-commit 16.0.8.2-stable^{commit}

zsh: no matches found: 16.0.8.2-stable^{commit}
zsh: exit 1 git verify-commit 16.0.8.2-stable^{commit}

Needs to be quoted in zsh. Functional:

git verify-commit "16.0.8.2-stable^{commit}"

Is it possible to change zsh behavior here?

Found this
https://zsh.sourceforge.io/Guide/zshguide05.html#l137

Apparently ^ means negation.

So [^[:digit:]]`' matches any single character other than a decimal digit. Standards say you should use !' instead of ``^’ to signify negation, but most people I know don’t; also, this can clash with history substitution. However, it is accepted by zsh anywhere where history substitution doesn’t get its hands on the ``!`’ first (which includes all scripts and autoloaded functions).

And also

Another two cryptic symbols are the two that do negation. These only work with the option ``EXTENDED_GLOB`’ set: this is necessary to get the most out of zsh’s patterns, but it can be a trap for the unwary by turning otherwise innocuous characters into patterns:

print ^foo

This means any file in the current directory except the file foo. One way of coming unstuck with ``^`’ is something like

stty kill ^u

where you would hope ^u`' means control with u', i.e. ASCII character 21. But it doesn't, if EXTENDED_GLOBis set: it meansany file in the current directory except one called ``u`’ ', which is definitely a different thing.

So if you want to not have to quote you can insert unsetopt extendedglob in your ~/.zshrc as it will override the option set on /etc/zsh/zshrc.dist.

Or if you prefer to remove from the default build?

1 Like

What’s the zsh default?

Maybe best to stick to zsh defaults?

zsh default is thin, slim, so not set.

so should I remove it?

1 Like

Yes, please. Otherwise I guess too some commands that users/copy paste might break. Even if the scripting is different, should be similar enough to bash in order not to break things.

Note: Since this is related… No, zsh won’t break random shell scripts.

(nyxnor knows that but mentioning here in case somebody else would wonder.)