Update $PATH variable permanently
Asked Answered
G

2

6

Apologies if this duplicate but a lot of other threads are years old.

I want to update my $PATH variable permanently so it doesn't reset everytime I quit Terminal. I have seen people suggest to run the following:

gedit ~/.bashrc

But this returns:

-bash: gedit: command not found

I have used Spotlight to search my hard disk for the .bashrc file and can't find it. Can anyone help?

Thanks in advance...

Gossipry answered 4/8, 2016 at 18:17 Comment(1)
gedit is a gnome text editor, use nano or something native to OS X instead.Toscanini
H
10

You don't need an editor for that, you can do this using bash's output redirection operation.

For example, to add /foo/bar you current PATH, append (>>) to ~/.bashrc:

echo 'export PATH="$PATH":/foo/bar' >> ~/.bashrc

To view the content to STDOUT too, use tee -a:

echo 'export PATH="$PATH":/foo/bar' | tee -a ~/.bashrc
Heterography answered 4/8, 2016 at 19:27 Comment(0)
B
1

the . before the file means it's hidden so that's probably why it didn't show, just like if you do ls from your home folder you won't see it but ls -la will

to edit your file I would suggest using vi instead if gedit is not available

vi ~/.bashrc

Billiot answered 4/8, 2016 at 19:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.