create a .bashrc

I'm very new to programming in UNIX and I'm trying to add the bin folder of the package i'm working with, so that command interpreter (Terminal) can find the programs.
As I understand it I need to add the instructions:

PATH=.:"/Users/Chris/clip/bin":$PATH
export PATH

to the file:
/Users/Chris/.bashrc
Although I don't think this file exists. How do I go about creating it and do I need to put any other instructions in there? Thanks,
Chris

power mac g5, Mac OS X (10.4)

Posted on Jun 22, 2007 3:03 PM

Reply
5 replies

Jun 22, 2007 5:46 PM in response to chris_antilectual

"PATH" refers to an environment variable that is inherited by each new shell level, so it is appropriate to place its definition in your .bash_profile (or .profile) file, not the .bashrc file. You probably already have one of these files, which already defines PATH. Just edit that definition to match your package's requirements, logout, and back in, and you should be in business.

BTW, Terminal is not the command interpreter; your shell is. By default, your shell is the "bash" program, /bin/bash. Terminal is only the user interface to the command interpreter.

Jun 22, 2007 3:50 PM in response to chris_antilectual

In BASH, you can make that all one statement:

export PATH="/Users/Chris/clip/bin:$PATH"

notice that I changed your end quote. Personally, I'd do:

export PATH="$PATH:/Users/Chris/clip/bin"

When you issue a command that doesn't start with a / , which signifies an absolute path like /Users/Chris/clip/bin/program, the shell will try prepending each path in the PATH environmental variable, in the order that they're listed, to your command until the shell doesn't get a "Command not found" error. Having your path at the start of the PATH variable means that it would be checked first.

If you're happy with your environment, you don't need anything else in .bashrc.

Roger

Jun 25, 2007 3:14 PM in response to chris_antilectual

If you're using the command-line interface, you'd need to know how to use a Unix text editor, e.g., vi or emacs. Presuming you know how to use vi, you would enter the following:
<pre class="command">cd
vi .bashrc</pre>
If you just want to see if it's there, enter the following:
<pre class="command">ls -a</pre>
The "-a" option causes it to display "hidden" files.

Jun 25, 2007 6:43 PM in response to chris_antilectual

I know how stupid I sound but how do I open and edit
this file? It must be hidden if it's there and I've
got no idea how to access it. Sorry, I'm very new to
all this,
Chris

power mac g5 Mac
OS X (10.4)


First, to see if the file exists, open Terminal.app (in Applications/Utilities) and type "ls -a ~/" This will list all of the file in your home directory. If .bashrc exists, then you can edit the file by typing "open -a /Applications/TextEdit.app .bashrc".

If the file doesn't exist, then open TextEdit, select Format=>Make Plain Text, then paste in the necessary commands. Once that's done, go to File=>Save As, uncheck "If no extension is provided, use ".txt", type in the name ".bashrc", and save the file. TextEdit will warn you that files beginning with a "." are reserved for the system. Click the "Use '.'" button, and you're all set.

MacBook C2D (home), PowerMac Dual G5 (work) Mac OS X (10.4.10)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

create a .bashrc

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.