MacOS – Bash commands not working as needs to be

bashcommand linemacospathterminal

First of all, the problems:

  • I'm not able to use both exported bash commands and default system bash commands at the same time
  • Some of the exported paths working on terminal but some of them not

Things I did:

I was adding exports to my .bash_profile but I got the problems, then I searched for solutions. Tried a couple of things. I'm not sure if I did something wrong or what.

  • Changed: Terminal -> Preferences -> Shells open with, then reverted to default
  • Deleted .bashrc and .bash_profile files then reverted them to the first state
  • Corrected the $PATH directory, did everything in this answer: https://superuser.com/a/498356

If I restart the terminal, default bash commands working but if I source the .bash_profile or .bashrc then some of the exports working some of not and the default bash command not working(e.g. open command not working).

How can I manage to get it to work simultaneously while all my additional bash commands working?

My .bash_profile:

export JAVA_HOME="/usr/lib/jvm/default-java"
export ANDROID_HOME=/Users/user/Library/Android/sdk
export PATH=/Users/user/Library/Android/sdk/platform-tools:$PATH
export PATH=/Users/user/Library/Android/sdk/tools:$PATH
export PATH=/Users/user/Library/Android/ndk-build:$PATH
export PATH=$PATH:~/Flutter/flutter/bin
export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"

Sorry, I'm searching for hours and there too many different kinds of questions, solutions, suggestions and it's hard to figure out what should I do exactly. Thanks in advance!

Best Answer

Remove the \ in front of $PATH in the last line and start a new shell