 |
 |
How to make commands in terminal system wide?
|
 |
|
 |
|
Grizzled Veteran
Join Date: Sep 2000
Location: The Basement
Status:
Offline
|
|
For example when I type PERL it just runs, doesn't matter what directory I am in.
I would like to be able to do this with a few of my applescripts and other applications so that when I'm SSHing remotely I can get a few things done in a hurry.
What is the best way?
Thanks.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: May 1999
Location: San Jose, CA
Status:
Offline
|
|
Originally posted by brainchild2b:
For example when I type PERL it just runs, doesn't matter what directory I am in.
I would like to be able to do this with a few of my applescripts and other applications so that when I'm SSHing remotely I can get a few things done in a hurry.
What is the best way?
Thanks.
Whenever you type a command at the shell prompt, the system looks at your $PATH to determine which directories to search, in order, to find the application.
You can see your $PATH at any time by simply running:
echo $PATH
If you want other applications to be launched by name (without the fill path), just include their directories in your $PATH.
For ease of use, add it to your .cshrc file so have these directories added to the $PATH each time you open a new shell.
Adding the line:
setenv PATH $PATH:/path/to/new/dir:/path/to/another/dir
to ~/.cshrc should add the two additional directories to your $PATH. Note the colon-delimited nature of the path list.
The alternative way would be to place links to the apps you want in the existing $PATH. In this way you can be more selective about which commands are available.
This approach doesn't require changing any shell variables or startup files:
sudo ln -s /path/to/app /bin
will place a link to /path/to/app in the /bin directory, so you can now type 'app' and launch it.
|
|
Gods don't kill people - people with Gods kill people.
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
Originally posted by Camelot:
Adding the line:
setenv PATH $PATH:/path/to/new/dir:/path/to/another/dir
to ~/.cshrc should add the two additional directories to your $PATH. Note the colon-delimited nature of the path list.
Ya know I can't remember ever having this much trouble trying to add a directory to my path, yet here I've been sitting for 20 minutes, giving up on my usual instinct and ability at finding these types of things...
I added setenv PATH $PATH:/usr/local/bin: to my .cshrc and upon sourcing my .cshrc I get: Bad : modifier in $ (/).
Ugh.  Thanks, Camelot. 
|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status:
Offline
|
|
Originally posted by [APi]TheMan:
Ya know I can't remember ever having this much trouble trying to add a directory to my path, yet here I've been sitting for 20 minutes, giving up on my usual instinct and ability at finding these types of things...
I added setenv PATH $PATH:/usr/local/bin: to my .cshrc and upon sourcing my .cshrc I get: Bad : modifier in $ (/).
Ugh. Thanks, Camelot.
setenv PATH $PATH:/usr/local/bin:
try removing the trailing : so that it looks like
setenv PATH $PATH:/usr/local/bin
If you want to make this extra path systemwide and not on a user by user basis you can place it in /etc/csh.login
Note: As convenient as it may seem... it is a VERY bad idea to put . in your path. This would put the current folder in the execution path which would make it a LOT easier to insert a trojan on your system.
|
|
-DU-...etc...
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
Originally posted by utidjian:
setenv PATH $PATH:/usr/local/bin:
try removing the trailing : so that it looks like
setenv PATH $PATH:/usr/local/bin
If you want to make this extra path systemwide and not on a user by user basis you can place it in /etc/csh.login
I tried playing with removing the trailing colon and slash, but it still errored.
I ended up just adding the directory to /etc/csh.login. I tried adding it to /usr/share/tcsh/examples/login , where I swear I've edited the aliases file and had it work... but editing that login file seemed to do nothing, probably because they're just examples, eh?
Anyways, thanks, utidjian. 
|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status:
Offline
|
|
Originally posted by [APi]TheMan:
I tried playing with removing the trailing colon and slash, but it still errored.
I ended up just adding the directory to /etc/csh.login. I tried adding it to /usr/share/tcsh/examples/login , where I swear I've edited the aliases file and had it work... but editing that login file seemed to do nothing, probably because they're just examples, eh?
Anyways, thanks, utidjian.
Whoops... my bad. Darn thing works in csh and bash. It should have been:
setenv PATH $PATH\:/usr/local/bin
for some reason tcsh requires the \ to escape the : (and after extensive man tcsh reading I still don't understand why!)
The above will append the /usr/local/bin to your $PATH. Alternatively you can prepend /usr/local/bin with:
setenv PATH /usr/local/bin:$PATH
Now... I DID test the above in a tcsh shell and they work ;-)
|
|
-DU-...etc...
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Aug 2002
Status:
Offline
|
|
This litle goodie puts terminal commands into a contextual menu 
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Nov 2001
Location: Adelaide, South Australia
Status:
Offline
|
|
I'm guessing that the problem witnessed above is due to the fact that tcsh
isn't seeing the colon as anything but part of the variable name. You need to
delimit the variable name with (eg) brackets: witness the following...
% echo $TERM
xterm-color
% echo $TERM:$PATH
Bad : modifier in $ ($).
% echo ${TERM}:${PATH}
xterm-color:/usr/local/bin:/sw/bin:/Users/pmccann/bin:/bin:/usr/X11R6/bin:/usr/bin:/usr/sbin:/sbin:
/usr/local/subversion/bin:/usr/local/teTeX/bin/powerpc-apple-darwin-current
That's why you often see the PATH defined using something like
setenv PATH ${PATH}:/another/directory
Of course the other option is to use a different shell! zsh or bash jump to mind,
and zsh is the provider of all my prompts these days. It's unreservedly great.
Cheers,
Paul
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Apr 2001
Location: Cary, NC
Status:
Offline
|
|
Also, put this in your .cshrc
alias addpath 'set path=($path \!^ )'
now (at least on a session by session basis) you can
addpath /foo/bar
And/or in your .cshrc, AFTER declaring the alias, you can do an addpath.
(note, I've uses this in tcsh for years), and also have the alias
alias prependpath 'set path=(\!^ $path )'
Cheers,
Mike
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|