问题
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?
回答1:
These are applicable to MacOS Sierra 10.12.5 (16F73) and probably some other recent and upcoming versions of MacOS.
chshis 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.'In case of bash, make sure that you execute
echo $BASH_VERSIONto confirm you are running the intended version of bash.bash --versiondoes not give you correct information.
回答2:
1. sudo nano /etc/shells
2. add /usr/local/bin/fish to your list of shells
3. chsh -s /usr/local/bin/fish
回答3:
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.
回答4:
From Terminal:
Add Fish to
/etc/shells, which will require an administrative password:sudo echo /usr/local/bin/fish >> /etc/shellsMake Fish your default shell with
chsh:chsh -s /usr/local/bin/fish
From System Preferences:
User and Groups → ctrl-click on Current User → Advanced Options...
Change Login shell to
/usr/local/bin/fish
Press OK, log out and in again
回答5:
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.
回答6:
The only thing that worked for me was a combination of all these methods.
First I had to add fish to the
/etc/shellsfileThen I ran
chsh -s /usr/local/bin/fishFinally, I typed Command+, and added
/usr/local/bin/fishto the default path there
Only after I had done all three things did fish start popping up as the default for new terminal windows.
回答7:
Mac OS X: How to change the Terminal shell
回答8:
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)
回答9:
- Open your terminal and press command+, (comma). This will open a preferences window.
- The first tab is 'General'.
- Find 'Shells open with' setting and choose 2nd option which needs complete path to the shell.
- Paste the link to your fish command, which generally is
/usr/local/bin/fish.
I am using macOS Sierra.
回答10:
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.
回答11:
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.
回答12:
This work for me on fresh install of mac osx (sierra):
- Define current user as owner of shells
sudo chown $(whoami) /etc/shells
- Add Fish to /etc/shells
sudo echo /usr/local/bin/fish >> /etc/shells
- Make Fish your default shell with chsh
chsh -s /usr/local/bin/fish
- Redefine root as owner of shells
sudo chown root /etc/shells
回答13:
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"
回答14:
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).
回答15:
In case you are having troubles with the other ways, worked on mac Mojave but should generally work.
which fish
add the output path to "System Preferences > Users & Groups > right click user, Advanced Options" Paste the result from which into "Login shell:"
来源:https://stackoverflow.com/questions/453236/how-to-set-my-default-shell-on-mac
