Differences between revisions 11 and 12
Revision 11 as of 2021-06-15 07:45:26
Size: 741
Editor: stroth
Comment:
Revision 12 as of 2021-06-15 08:31:26
Size: 1161
Editor: stroth
Comment:
Deletions are marked like this. Additions are marked like this.
Line 13: Line 13:
if shopt -q login_shell; then
    export SHELL=/bin/zsh
    exec /bin/zsh
if [[ $- == *i* ]]; then
    # This is an interactive shell
    if [[ "${0}" == "-bash" || "${0}" == "bash" ]]; then
        # This is a bash login or non-login bash shell
        if [[ -x /bin/zsh ]]; then
            # zsh is present and executable
            export SHELL=/bin/zsh
            exec /bin/zsh
        fi
    fi
Line 18: Line 25:
/!\ 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.

  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 a bash login or non-login bash 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)