mostlyConfused
mostlyConfused

Reputation: 83

Messed up $PATH(i think) in zsh

When i try to do ls in the terminal, it says command not found.

Before I broke everything, the output of echo $PATH was something like this:

/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/gabrijelagavric/.gem/ruby/2.6.5/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/bin:

I was trying to follow along with some threads but I don't seem to understand what specifically I need to run to change my .zshrc file (this thread said to change PATH variable in .zshrc: commands not found on zsh)

So, I pasted this into the terminal:

echo "export PATH=/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/gabrijelagavric/.gem/ruby/2.6.5/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/bin:" >> ~/.zshrc

And then source ~/.zshrc"

But then i got this response

/Users/gabrijelagavric/.oh-my-zsh/oh-my-zsh.sh:117: command not found: rm
detect-clipboard:33: command not found: uname
/usr/local/opt/chruby/share/chruby/chruby.sh:5: command not found: ls
/Users/gabrijelagavric/.zshrc:export:107: not valid in this context: /Users/gabrijelagavric/.gem/ruby/2.6.5/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/bin:``` 

Upvotes: 1

Views: 10041

Answers (3)

DroidClicketyClacker
DroidClicketyClacker

Reputation: 2092

Since I broke my path while tweaking things in my .zshrc, I could not enable "show hidden files" with the terminal command. Here are the steps I took:

  1. Download an IDE of your choosing (VS Code, Atom, Sublime, etc)
  2. Open Finder and navigate to your user (you can right click the folder name at the top to get a dropdown of your current folder and it's parents)
  3. Press⌘⇧.(Command-Shift-Dot) to show hidden files.
  4. Right click your .zshrc file and select "Open With"
  5. Choose your IDE/editor
  6. Make your changes and save

Upvotes: 0

mostlyConfused
mostlyConfused

Reputation: 83

The way I fixed this was following the answer provided by "user1934428" in their comment (though they didn't actually answer it so I don't know how to specify they resolved it"

Their suggestion was to edit the file in a text editor.

  1. opened vs code
  2. file > open
  3. show hidden files (.zshrc) via cmd+shift+"." (for mac)
  4. made changes
  5. saved

Thank you user1934428, your solution helped. Thank you to Mashuptwice and Chapner as well for answering as well.

Upvotes: 5

mashuptwice
mashuptwice

Reputation: 695

You've added the new $PATH variable as last line (>>) to your .zshrc file. Remove the last line of the file to revert the changes.

If you want to add a path to $PATH in the future, you can use PATH=$PATH:/new/path/appended/to/variable to add something to the variable, without completely replacing it.

Upvotes: 0

Related Questions