How to make zsh run as a login shell on Mac OS X (in iTerm)?

前端 未结 6 2407
闹比i
闹比i 2020-12-22 16:23

When zsh is set as a login shell on Mac OS X, when it is started by iTerm, zsh doesn\'t consider that it\'s being run as a login shell, although it\'s started as ‘-zsh’ (‘-’

相关标签:
6条回答
  • 2020-12-22 16:42

    Go to the Users & Groups pane of the System Preferences -> Select the User -> Click the lock to make changes (bottom left corner) -> right click the current user select Advanced options... -> Select the Login Shell: /bin/zsh and OK

    0 讨论(0)
  • 2020-12-22 16:54
    chsh -s $(which zsh)
    

    You'll be prompted for your password, but once you update your settings any new iTerm/Terminal sessions you start on that machine will default to zsh.

    0 讨论(0)
  • 2020-12-22 17:02

    Use the login utility to create a login shell. Assume that the user you want to log in has the username Alice and that zsh is installed in /opt/local/bin/zsh (e.g., a more recent version installed via MacPorts). In iTerm 2, go to Preferences, Profiles, select the profile that you want to set up, and enter in Command:

    login -pfq Alice /opt/local/bin/zsh
    

    See man login for more details on the options.

    0 讨论(0)
  • 2020-12-22 17:05

    In iTerm -> Preferences -> Profiles Tab -> General section set Command to: /bin/zsh --login

    /bin/zsh --login

    0 讨论(0)
  • 2020-12-22 17:05

    Have you tried editing the shell entry in account settings.

    Go to the Accounts preferences, unlock, and right-click on your user account for the Advanced Settings dialog. Your shell should be /bin/zsh, and you can edit that invocation appropriately (i.e. add the --login argument).

    0 讨论(0)
  • 2020-12-22 17:07

    The command to change the shell at startup is chsh -s <path_to_shell>. The default shells in mac OS X are installed inside the bin directory so if you want to change to the default zsh then you would use the following

    chsh -s /bin/zsh
    

    If you're using different version of zsh then you might have to add that version to /etc/shells to avoid the nonstandard shell message. For example if you want home-brew's version of zsh then you have to add /usr/local/bin/zsh to the aforementioned file which you can do in one command sudo sh -c "echo '/usr/local/bin/zsh' >> /etc/shells" and then run

    chsh -s /usr/local/bin/zsh
    

    Or if you want to do the whole thing in one command just copy and paste this if you have zsh already installed

    sudo sh -c "echo '/usr/local/bin/zsh' >> /etc/shells" && chsh -s /usr/local/bin/zsh
    
    0 讨论(0)
提交回复
热议问题