bash to zsh in terminal issue

I tried to change bash to zsh, did the update command, and typed my password but it responded with -bash: .: filename argument required What do I need to type in next?

Posted on Dec 7, 2023 8:20 AM

Reply
Question marked as Top-ranking reply

Posted on Dec 7, 2023 11:38 AM

Here is what you need to do in order to switch to the Zsh shell from Bash: In the Terminal application:


sudo /usr/bin/chsh -s /bin/zsh


Since Zsh does not read the Bash startup dotfiles, nor does it create its own, you will need to create the $HOME/.zshrc file minimally configured with your PATH and PS1 prompt exports. Zsh's PS1 prompts are different syntax from Bash. If you have already done this, then ignore the following HERE script. Otherwise, copy/paste this into the Terminal and follow it with a return to run it:


<<"EOF" > ~/.zshrc
export PATH=".:/usr/local/bin:${PATH}"
PS1="%m: %~ %% "
EOF


Once that is done, you can set your PATH and PS1 prompt in the current Terminal session instead of quitting and restarting Terminal:


source ~/.zshrc


There is available documentation on the Zsh prompt and Zsh shell in general.


One indispensible function that you should put in your $HOME/.zshrc file is the following:


hgrep () { fc -Dlim "*$@*" 1 }


This will let you locate any prior command or part of a command line that you may have entered earlier. Let's say you opened a PDF from the command line 20 commands ago as:


open -a Preview kant_jacobian_3u.pdf


You find that command with:


hgrep Preview
hgrep kant



Additional reading:


Zsh Helpful Wiki

Zsh Native Scripting Handbook

Better Zsh History


I have had some really good links to Zsh material but many of the important ones have either become dead links, or saturated with clickbait advertisements.

1 reply
Question marked as Top-ranking reply

Dec 7, 2023 11:38 AM in response to Jazzy-8

Here is what you need to do in order to switch to the Zsh shell from Bash: In the Terminal application:


sudo /usr/bin/chsh -s /bin/zsh


Since Zsh does not read the Bash startup dotfiles, nor does it create its own, you will need to create the $HOME/.zshrc file minimally configured with your PATH and PS1 prompt exports. Zsh's PS1 prompts are different syntax from Bash. If you have already done this, then ignore the following HERE script. Otherwise, copy/paste this into the Terminal and follow it with a return to run it:


<<"EOF" > ~/.zshrc
export PATH=".:/usr/local/bin:${PATH}"
PS1="%m: %~ %% "
EOF


Once that is done, you can set your PATH and PS1 prompt in the current Terminal session instead of quitting and restarting Terminal:


source ~/.zshrc


There is available documentation on the Zsh prompt and Zsh shell in general.


One indispensible function that you should put in your $HOME/.zshrc file is the following:


hgrep () { fc -Dlim "*$@*" 1 }


This will let you locate any prior command or part of a command line that you may have entered earlier. Let's say you opened a PDF from the command line 20 commands ago as:


open -a Preview kant_jacobian_3u.pdf


You find that command with:


hgrep Preview
hgrep kant



Additional reading:


Zsh Helpful Wiki

Zsh Native Scripting Handbook

Better Zsh History


I have had some really good links to Zsh material but many of the important ones have either become dead links, or saturated with clickbait advertisements.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

bash to zsh in terminal issue

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.