The Broken Terminal
So, I just got my new laptop.
And I want to set it up so that I can do some coding on my machine.
Turns out there are 3 kinds of shell options in Mac OS; the bash profile, the zprofile, and the zshrc, and so on...
Anddd.... while experimenting on something, I kinda broke my terminal so common commands like ls
or sudo
or even brew
are not working anymore in the terminal. It always says bash: xxxx: command not found
So, after doing some digging I found a way out of this misfortunate situation.
The key takeaway here is to set the PATH
first, or one could say that we need to set the PATH
to the 'standard path' that MacOS uses. And the default mandatory would be some directory in usr/local/bin. So this the step-by-step to fix the broken terminal:
Open the terminal
Type in the following command
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
After that, we could open the nano or vim or vi or whatever text editor you use to add the standard path to the bash config file.
For me, the command would be
nano ~/.zshrc
Also, don't forget to copy and paste the 'standard path' in no 2 to the content of the zsh file
Save the file, and then try out the standard command you would like to use.
External Resources (Further Reading) :
https://www.cyberciti.biz/faq/change-default-shell-to-bash-on-macos-catalina/