Differences between revisions 7 and 14 (spanning 7 versions)
Revision 7 as of 2020-09-09 11:49:33
Size: 528
Editor: bonaccos
Comment:
Revision 14 as of 2023-02-22 11:46:38
Size: 1196
Editor: bonaccos
Comment: clarify that zsh may not be installed everywhere
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
#rev 2020-09-09 bonaccos #rev 2020-10-22 bonaccos
Line 5: Line 5:
Everybody on the system has to use `bash` as login shell, because this allows us to put a standard configuration into each account. Everybody on the system has to use `bash` as login shell, because this allows us to put a standard configuration into each account. This remains the default shell of a User.
Line 7: Line 7:
But don't worry, it's no problem to change the shell for all further operations after the login. Just put `export SHELL=/bin/zsh` into your `~/.bashrc` or `setenv SHELL /bin/zsh` in your `~/.cshrc` (in case you where not yet switched to bash as default shell and still have it set to `tcsh`). But don't worry, it's no problem to change the shell for all further operations after the login if `zsh` is available on the system.

 1. Create a backup of your `~/.bashrc`, as it will be replaced to start `zsh` and not do anything else {{{#!highlight bash numbers=disable
cp ~/.bashrc ~/.bashrc.bak
}}}
 1. Replace the content of `~/.bashrc` with the following commands: {{{#!highlight bash numbers=disable
if [[ $- == *i* ]]; then
    # This is an interactive shell
    if [[ "${0}" == "-bash" || "${0}" == "bash" ]]; then
        # This is bash and a login or non-login shell
        if [[ -x /bin/zsh ]]; then
            # zsh is present and executable
            export SHELL=/bin/zsh
            exec /bin/zsh
        fi
    fi
fi
}}}
/!\ This only replaces `bash` with `zsh` for interactive shells, make sure you adapt your cronjobs and scripts yourself in case you want to use `zsh` there.

How can I have zsh as my default shell?

Everybody on the system has to use bash as login shell, because this allows us to put a standard configuration into each account. This remains the default shell of a User.

But don't worry, it's no problem to change the shell for all further operations after the login if zsh is available on the system.

  1. Create a backup of your ~/.bashrc, as it will be replaced to start zsh and not do anything else

    cp ~/.bashrc ~/.bashrc.bak
    
  2. Replace the content of ~/.bashrc with the following commands:

    if [[ $- == *i* ]]; then
        # This is an interactive shell
        if [[ "${0}" == "-bash" || "${0}" == "bash" ]]; then
            # This is bash and a login or non-login shell
            if [[ -x /bin/zsh ]]; then
                # zsh is present and executable
                export SHELL=/bin/zsh
                exec /bin/zsh
            fi
        fi
    fi
    

/!\ This only replaces bash with zsh for interactive shells, make sure you adapt your cronjobs and scripts yourself in case you want to use zsh there.


CategoryLXCL

FAQ/ZshAsDefaultShell (last edited 2023-02-22 11:46:38 by bonaccos)