I am using the z Shell (zsh) instead of the default bash, and something wrong happen so that all commands who used to work are no longer recognized:
<
Restarting the terminal also made the trick for me.
It's evident that you've managed to mess up your PATH variable. (Your current PATH doesn't contain any location where common utilities are located.)
Try:
PATH=/bin:/usr/bin:/usr/local/bin:${PATH}
export PATH
Alternatively, for "resetting" zsh, specify the complete path to the shell:
exec /bin/zsh
or
exec /usr/bin/zsh
if you are using macOS, try to follow this step
if you write the code to export PATH in ~/.bash_profile then don't miss the Step 1
Step 1:
.bash_profile is loaded when your terminal is an open, check on your ~/.bashrc or ~/.zshrc (if you are using zsh), is there any code similar source ~/.bash_profile or not?. if not you can add manually with adding code source ~/.bash_profile in there.bash_profile > export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin if it not in there, add that code into itSep 2:
"Visual Studio Code.app" is in the right place > "/Applications" or "/Users/$(whoami)/Applications"rm -rf /usr/local/bin/codeCMD+Shift+P and then select "Shell Command: Instal "code" command in PATH"code -v, it should be workIn your ~/.zsh config file include the path to your bash path file that contains your aliases. In my case it was including the line "source ~/.bash_profile" inside of ~/.zsh .
As others have said, simply restarting the terminal after you've made changes should reset and changes you've made to your ~/.zshrc file. For instance after adding function to open visual studio:
function code {
if [[ $# = 0 ]]
then
open -a "Visual Studio Code"
else
local argPath="$1"
[[ $1 = /* ]] && argPath="$1" || argPath="$PWD/${1#./}"
open -a "Visual Studio Code" "$argPath"
fi
}
I was able to use the keyword code to open the program from the command line.
In my case I was using the variable path in lowercase!
So in /etc/profile.d I was running a script that made use of the variable path. Because it was in lowercase I never thought it could mess up with the actual variable PATH. Be careful and do not use the variable path on your scripts.