For mistake I have added a path that I don't want to use.
I have create a file named .base_profile, exported the path using the command source .base_profile, but I don't need this path, how to delete it?
Maybe the title wasn't so appropriate, but I haven't modified the PATH variable.
I have written this in the .base_profile file:
export MP=$MP/usr/local/mysql/bin
And then used the source command.The problem is with the MP variable, which is not one that I want, it's too long.I want to delete it, how to do it?
The way to restore your path to the default is PATH=$(getconf PATH)
Do an
echo $PATH
Then grab with the mouse that part, which looks useful, and append it to:
PATH=
So for example - not on an OSX-System:
PATH=/home/ramy/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
If you only sourced the path in one terminal, you can, alternatively, open a new terminal.
If you added the source-command to one configuration script, you have to remove it there, to get rid of it permananetly.
Fix your errors in the file, and fix the env var with
export PATH=[the correct one]
Related
So I wanted to install MySQL on my MBP and I edited my bash_profile, added a path variable, however when I run echo $PATH from iTerm2 I get my path as:
Robs-MBP:~ Rob$ echo $PATH
/usr/local/mysql/bin
Ive tried a lot of commands and even used sudo and it just says command not found. My fear is that I have completely messed up, and now nothing works. Please help.
You've made a simple mistake: all you've done is reset the PATH env variable. To correctly do this, you should always add the existing PATH to the end of whatever you're adding. In you case:
PATH=/usr/local/mysql/bin:$PATH
To fix your problem from the terminal, you'll need to reset your PATH to somewhere with a text editor. I don't know where this is located on OSX, so you'll have to find it. After you know where your path should point, run:
$ export PATH=<YOUR_PATH_HERE>
Then edit your bashrc to include the original path as described above, and restart the terminal.
Alternatively, open .bashrc with a GUI text editor and make the change from there. Your PATH decleration should always end in :$PATH to include the PATH created by your system.
I tried to make iverilog command s.t I can run verilog program on my Macbook Air.
After few steps for installing the files, the tutorial told me to type:
export PATH=~/bin:/usr/local/iverilog/bin
It worked in terms of iverilog command, i.e, I can compile .v file. However, normal command like ls, man,etc.
I guess it is the problem of the PATH of the command sets, which means those normal unix command is not located.
Can someone tell me how to fix it and I dont need to export the PATH everytime?
You didn't add your paths to the current paths established by the OS. Instead, you replaced it with your paths. This is what you need to do in order to add paths to your PATH variable:
export PATH=$PATH:~/bin:/usr/local/iverilog/bin
The $PATH part is your current PATH value, which is added (concatenated actually) to the list of new paths you want to add. This is turn is assigned to PATH variable.
To make this additions permanent, you may want to add the above line to the end of your .profile file, or .bash_profile (whatever you have in OS X)
You can also do as this:
http://architectryan.com/2012/10/02/add-to-the-path-on-mac-os-x-mountain-lion/
Which says that you can edit the file /etc/paths and add whatever paths you want to add, one per line, then save that file and your added paths are available. In this case, just remember to use absolute paths. That is, paths starting with / . The first one you use: ~/bin is not an aboslute path. You need to convert it to an absolute path. To do this, remember that ~ is a shortcut to your HOME directory: something like /Users/myloginname. Type echo $HOME to find it out.
Using z in zsh, I want to change the default location of where the history is kept.
By default, when your source the shell script
source ~/z/z.sh
It will make a file with the directories you visit in a .z/ directory. While this is fine for most cases, I want to change this to another directory. The README.md does state that you can set some variables for this in my .zshrc
Optionally:
Set $_Z_DATA to change the datafile (default $HOME/.z).
So I added this
export $_Z_DATA="$HOME/.z-history"
But for some reason, I get a warning that my shell can't find the directory.
Any idea why this is happening? Any help is appreciated.
You are having a typo, or haven't yet get how the bash variable works.
You do not need to use $ when declaring a variable. Only when you want to access it.
So just adapt you config with:
export _Z_DATA="$HOME/.z-history"
voilĂ :) it should works
I haven't been able to find the answer to this anywhere and suspect it's not possible. I'd like to know if I can somehow override environment variables set by export MY_VARIABLE="some-value" per directory. Meaning, once I cd into a particular directory where x variable is overridden, anything being run from that directory would see the new value.
Is that possible without expicitly exporting? Perhaps adding some file to the directory like .bashrc or something like that?
Thank you!
I've been struggling with "PATH" issues while setting up Rails and other things on Mac for a long time now, and I can't get a straight answer about how I can just see my $PATH and change it. I'm just running the Terminal right now, but if I need to run another program to run Bash commands or something I can probably figure out how to do that.
Execute the following command in Terminal to view the current value of PATH:
echo $PATH
To modify this PATH variable, create a .bash_profile file in your home directory (/Users/username/.bash_profile) and add a line similar to this:
export PATH=$PATH:/new/directory/location
To see your current PATH,
echo $PATH
in a Terminal window.
type:
echo $PATH
You can check your .bash_profile file and edit $PATH variable there. If that file does not exists then you can create a new one and you can export PATH there using:
export PATH=/usr/local/bin:/usr/local/mysql/bin:$PATH