Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > How to add paths to tcsh

How to add paths to tcsh
Thread Tools
qnxde
Grizzled Veteran
Join Date: Jul 2001
Location: Sydney, Australia
Status: Offline
Reply With Quote
Nov 11, 2002, 01:06 AM
 
How do you add paths to tcsh in a normal 10.2 install? I just can't work it out. Say I want to add /sw/bin into my path (fink didn't do it automatically for some reason), where would I enter that? I can do it for bash, but I dislike bash and would rather use tcsh. Any help?

You can't eat all those hamburgers, you hear me you ridiculous man?
     
graffix
Dedicated MacNNer
Join Date: May 2001
Location: Sierra Nevada Country
Status: Offline
Reply With Quote
Nov 11, 2002, 04:56 AM
 
for fink, just add this line
Code:
source /sw/bin/init.csh
to your ~/.cshrc file.
That should do the trick.
If in the future you wish to add more paths to your path environment variable, just add this line:
Code:
setenv PATH "{$PATH}:/new/path/to/add"
to the same file I mentioned previously, then either open a new terminal window or type 'source ~/.cshrc' to activate the path change. You can also add the new path 'before' the {$PATH} part and the shell will search the new path first, before searching the rest of the paths (just reverse the order I showed).
Hope that helps ya.
First there was man, then there was Macintosh
     
qnxde  (op)
Grizzled Veteran
Join Date: Jul 2001
Location: Sydney, Australia
Status: Offline
Reply With Quote
Nov 11, 2002, 06:18 AM
 
That line for fink is present, however it still doesn't work for some reason (strange, I know). You might find this interesting.

Last login: Mon Nov 11 21:08:24 on ttyp1
Welcome to Darwin!
[agnetham:~] benw% cat .cshrc
setenv PATH "${PATH}:/testdir"
[agnetham:~] benw% echo $PATH
/Users/benw/bin/powerpc-apple-darwin:/Users/benw/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
[agnetham:~] benw%

And yes, there is a dir called "testdir" in /


Any ideas?

Originally posted by graffix:
for fink, just add this line
Code:
source /sw/bin/init.csh
to your ~/.cshrc file.
That should do the trick.
If in the future you wish to add more paths to your path environment variable, just add this line:
Code:
setenv PATH "{$PATH}:/new/path/to/add"
to the same file I mentioned previously, then either open a new terminal window or type 'source ~/.cshrc' to activate the path change. You can also add the new path 'before' the {$PATH} part and the shell will search the new path first, before searching the rest of the paths (just reverse the order I showed).
Hope that helps ya.

You can't eat all those hamburgers, you hear me you ridiculous man?
     
graffix
Dedicated MacNNer
Join Date: May 2001
Location: Sierra Nevada Country
Status: Offline
Reply With Quote
Nov 11, 2002, 03:27 PM
 
Hrm...
maybe try the same path argument without the '{}'. I move so much between the bash and tcsh shells that I forget which commands go to which.
As to the problem with your .cshrc not executing the init.csh script, there could be a few different causes:
1. Improper permissions on the script
2. Having a .tcshrc file in your home directory
3. not having a carriage return in your .cshrc file after the 'source...' line.

I'd check these things first.
The permissions problem can be solved by typing:
Code:
sudo chmod 755 /sw/bin/init.csh
This makes it executable by any user.
The next most common problem is adding the 'source' line to your .cshrc without hitting 'return' at the end of typing it.
In order for it to execute, there has to be an end-of-line marker such as a carriage return. Make sure your .cshrc file is correct and has an (invisible) return after the command.
You may also have a .tchsrc file in your home directory, which I think the tcsh shell prioritizes over a .cshrc file. In other words, your shell may not be reading the right config file. If you have any data in the .tcshrc file, you can append it to the .cshrc file with this command:
Code:
cat ~/.tcshrc >> ~/.cshrc
then remove the .tcshrc file.
Other than that, I don't know what else could be going wrong...
What happens when you just type 'source /sw/bin/init.csh' at a command prompt?
First there was man, then there was Macintosh
     
Gary Kerbaugh
Dedicated MacNNer
Join Date: Jul 2001
Location: NC
Status: Offline
Reply With Quote
Nov 12, 2002, 12:58 AM
 
   Naturally I think that setenv for $PATH should work. However, everything I read sets $path with a different syntax from every other environment variable. Further, nothing I read explains the syntax but they are consistent. The syntax uses set instead of setenv, an equals, "=", an enclosing parenthesis and a space delimited list. I do recall this from csh. An example looks like:

set path = ( $path /<new>/<dir> )

&nbsp;&nbsp;&nbsp;Again, I have no explaination for the syntax but I'd eagerly read any reference that anyone knows of that explains it.
Gary
A computer scientist is someone who, when told to "Go to Hell", sees the
"go to", rather than the destination, as harmful.
     
Wevah
Senior User
Join Date: Nov 2001
Location: State of Denial
Status: Offline
Reply With Quote
Nov 12, 2002, 01:27 PM
 
Try putting the $ OUTSIDE of the {}'s; i.e., ${PATH} instead of {$PATH} .
[Wevah setPostCount:[Wevah postCount] + 1];
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 02:10 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,