How to set my default shell on Mac?

前端 未结 16 874
抹茶落季
抹茶落季 2020-11-30 16:23

I do not like to retype fish every time I start terminal. I want fish on by default. How can I set fish shell as my default shell on a Mac?

相关标签:
16条回答
  • 2020-11-30 17:17

    These are applicable to MacOS Sierra 10.12.5 (16F73) and probably some other recent and upcoming versions of MacOS.

    1. chsh is not enough to change the default shell. Make sure you press Command+, while your terminal is open and change the 'Shells open with' option to 'Default login shell.'

    2. In case of bash, make sure that you execute echo $BASH_VERSION to confirm you are running the intended version of bash. bash --version does not give you correct information.

    0 讨论(0)
  • 2020-11-30 17:17

    Mac OS X: How to change the Terminal shell

    0 讨论(0)
  • 2020-11-30 17:21

    To change your default shell on mac run the following:

    chsh -s <name-of-shell>
    

    List of shells you can choose from are:

    1. /bin/bash
    2. /bin/csh
    3. /bin/dash
    4. /bin/ksh
    5. /bin/sh
    6. /bin/tcsh
    7. /bin/zsh

    so if you want to change from to the /bin/zsh shell, your command will look like:

    chsh -s /bin/zsh
    

    you can see all the available shells on your system by running:

    cat /etc/shells
    
    0 讨论(0)
  • 2020-11-30 17:22

    Here's another way to do it:

    Assuming you installed it with MacPorts, which can be done by doing:

    sudo port install fish
    

    Your shell will be located in /opt/local/bin/fish.

    You need to tell OSX that this is a valid shell. To do that, add this path to the end of the /etc/shells file.

    Once you've done this, you can change the shell by going to System Preferences -> Accounts. Click on the Lock to allow changes. Right-click on the account, and choose "Advanced Options...". In the "Login shell" field, add the path to fish.

    0 讨论(0)
  • 2020-11-30 17:22
    heimdall:~ leeg$ dscl
    Entering interactive mode... (type "help" for commands)
     > cd /Local/Default/Users/
    /Local/Default/Users > read <<YOUR_USER>>
    [...]
    UserShell: /bin/bash
    /Local/Default/Users >
    

    just change that value (with the write command in dscl).

    0 讨论(0)
  • 2020-11-30 17:25

    the chsh program will let you change your default shell. It will want the full path to the executable, so if your shell is fish then it will want you to provide the output given when you type which fish.

    You'll see a line starting with "Shell:". If you've never edited it, it most likely says "Shell: /bin/bash". Replace that /bin/bash path with the path to your desired shell.

    0 讨论(0)
提交回复
热议问题