Mac OS系统下如何将zsh shell切换为git shell?
Hey there! I totally get how frustrating it can be when gulp builder throws unexpected issues, and switching to Git Shell might help resolve environment-related glitches. Let's walk through the steps to make this change on your Mac:
First, locate the Git Shell executable path
Open your current zsh terminal and run this command to find where git-shell is installed:which git-shellYou'll get a path like
/usr/local/bin/git-shell(for Intel Macs) or/opt/homebrew/bin/git-shell(for Apple Silicon). Keep this path handy—you'll need it later.Add Git Shell to macOS's allowed shells list
macOS only lets you use shells listed in/etc/shellsas your default login shell. To add git-shell here:- Run this command to edit the file with sudo privileges:
sudo nano /etc/shells - Scroll to the bottom of the file and paste the path you found earlier (e.g.,
/usr/local/bin/git-shell). - Press
Ctrl + Oto save the changes, thenCtrl + Xto exit nano.
- Run this command to edit the file with sudo privileges:
Set Git Shell as your default shell
Now run this command to switch your default shell, replacing the path with the one you noted:chsh -s /usr/local/bin/git-shellEnter your user password when prompted, then close and reopen your terminal—you should now be in Git Shell.
A quick heads-up
Git Shell is a restricted shell designed primarily for Git operations. If you find that gulp still isn't working as expected, it might be because some commands or environment variables aren't accessible in this restricted context. In that case, you might want to check if your gulp setup is properly configured with Git's environment, or consider using a standard bash/zsh shell with Git fully integrated instead.
内容的提问来源于stack exchange,提问作者Pavel Dzemidovich

