How to set my default shell on Mac?

前端 未结 16 873
抹茶落季
抹茶落季 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:02

    From Terminal:

    1. Add Fish to /etc/shells, which will require an administrative password:

      sudo echo /usr/local/bin/fish >> /etc/shells
      
    2. Make Fish your default shell with chsh:

      chsh -s /usr/local/bin/fish
      

    From System Preferences:

    1. User and Groups → ctrl-click on Current User → Advanced Options...

    2. Change Login shell to /usr/local/bin/fish

      login shell

    3. Press OK, log out and in again

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

    On macOS Mojave I had to do the following (using zsh as an example):

    brew install zsh
    sudo sh -c "echo $(which zsh) >> /etc/shells"
    chsh -s $(which zsh)
    
    0 讨论(0)
  • 2020-11-30 17:10

    You can use chsh to change a user's shell.

    Run the following code, for instance, to change your shell to Zsh

    chsh -s /bin/zsh
    

    As described in the manpage, and by Lorin, if the shell is not known by the OS, you have to add it to its known list: /etc/shells.

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

    How to get the latest version of bash on modern macOS (tested on Mojave).

    brew install bash
    which bash | sudo tee -a /etc/shells
    chsh -s $(which bash)
    

    Then you are ready to get vim style tab completion which is only available on bash>=4 (current version in brew is 5.0.2

    # If there are multiple matches for completion, Tab should cycle through them
    bind 'TAB':menu-complete
    
    # Display a list of the matching files
    bind "set show-all-if-ambiguous on"
    
    # Perform partial completion on the first Tab press,
    # only start cycling full results on the second Tab press
    bind "set menu-complete-display-prefix on"
    
    0 讨论(0)
  • 2020-11-30 17:14

    When in the terminal, open the terminal preferences using Command+,.

    On the Setting Tab, select one of the themes, and choose the shell tab on the right.

    You can set the autostart command fish.

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

    The only thing that worked for me was a combination of all these methods.

    1. First I had to add fish to the /etc/shells file

    2. Then I ran chsh -s /usr/local/bin/fish

    3. Finally, I typed Command+, and added /usr/local/bin/fish to the default path there

    Only after I had done all three things did fish start popping up as the default for new terminal windows.

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