LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Other *NIX
User Name
Password
Other *NIX This forum is for the discussion of any UNIX platform that does not have its own forum. Examples would include HP-UX, IRIX, Darwin, Tru64 and OS X.

Notices


Reply
  Search this Thread
Old 05-25-2010, 08:26 PM   #1
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Rep: Reputation: 78
tired of typing full path to php or mysql...some way to create alias?


I do some development on a Max running OSX and I'm getting really tired of typing the full path to PHP (i.e., /Applications/MAMP/bin/php5/bin/php) or mysql or mysql dump each and every time i want to run a little script or do a db dump.

Can someone tell me where I could put an alias or perhaps edit my bash config files so I can avoid typing this entire thing every single time?
 
Old 05-25-2010, 08:40 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Check your ~/.bashrc ... if there's a PATH variable being set, edit it; if there
isn't, create an entry:
Code:
export PATH=$PATH:/Applications/MAMP/bin/php5/bin:/Applications/MAMP/bin/mysql/bin:.


Cheers,
Tink


P.S.: And since I have no idea whether or not MacOS has preserved these
features I've moved the thread to the right place.
 
Old 05-26-2010, 01:17 PM   #3
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
Hm...no joy on .bashrc I did a complete search:
Code:
My-Mac:/ user$ sudo find * -name '.bashrc'
Password:
My-Mac:/ user$
Would it work to add a symbolic link or file alias to one of the folders in the path?
Code:
My-Mac:/ user$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
Which path then? I'm not really sure what each of these paths is for. Also, won't creating an alias in one of these folders make the alias available to all users on the machine?

If there's some common term for this information I'm after here, I'd be glad to google it.
 
Old 05-26-2010, 02:09 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
It would work, but it's "unclean". You'd be better off to create a
~/.bashrc for your user-account and simply add the
Code:
export PATH=...
mumble-jumble, and (for good measure) source that from ~/.bash_profile
if it exists (again, if it doesn't, create it).
Code:
if [ -e ~/.bashrc ]; then
  source ~/.bashrc
fi


Cheers,
Tink
 
Old 05-26-2010, 02:22 PM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by sneakyimp View Post
Would it work to add a symbolic link or file alias to one of the folders in the path?

Which path then? I'm not really sure what each of these paths is for. Also, won't creating an alias in one of these folders make the alias available to all users on the machine?
Yes. EDIT: for symbolic link. IDK what "file alias" is.
/usr/local/bin is the most appropriate.
Yes.

An alternative would be to set a variable in ~/.bashrc like
Code:
PHP=/Applications/MAMP/bin/php5/bin/php
then instead of having to type /Applications/MAMP/bin/php5/bin/php/my_script.sh you could type $PHP/my_script.sh

Last edited by catkin; 05-26-2010 at 02:23 PM.
 
Old 05-26-2010, 02:27 PM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by sneakyimp View Post
If there's some common term for this information I'm after here, I'd be glad to google it.
For the conventional usage of Linux directories: Filesystem Hierarchy Standard (FHS).

For ~/.bashrc, ~/.bash_profile and others: Bash Startup Files.
 
Old 05-26-2010, 03:33 PM   #7
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
Alright then so my ~/.bashrc now contains this:
Code:
export PATH=$PATH:/Applications/MAMP/bin/php5/bin:/Applications/MAMP/Library/bin:.
and my ~/.bash_profile contains this (which is necessary for the initial login to have the extra PATH info)
Code:
if [ -e ~/.bashrc ]; then
  source ~/.bashrc
fi
I've logged out and logged back in and then created subshells and it appears to alter the PATH properly without adding it twice or whatever.

Additionally, i can just type 'php' or 'mysql' or whatever instead of the entire path.

THANKS!
 
Old 05-26-2010, 10:51 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by sneakyimp View Post
Alright then so my ~/.bashrc now contains this:
Code:
export PATH=$PATH:/Applications/MAMP/bin/php5/bin:/Applications/MAMP/Library/bin:.
and my ~/.bash_profile contains this (which is necessary for the initial login to have the extra PATH info)
Code:
if [ -e ~/.bashrc ]; then
  source ~/.bashrc
fi
I've logged out and logged back in and then created subshells and it appears to alter the PATH properly without adding it twice or whatever.

Additionally, i can just type 'php' or 'mysql' or whatever instead of the entire path.

THANKS!
Sweet ... glad you're sorted.


Cheers,
Tink
 
  


Reply



Posting 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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Invoking a PHP script - sometimes the full path is required sneakyimp Linux - Newbie 4 05-26-2008 05:38 PM
WPA-PSK passphrase: tired of typing it! litlmary Linux - Wireless Networking 3 09-26-2006 01:49 PM
Create alias in MySQL? JockVSJock Slackware 2 02-23-2006 09:15 PM
get full path of uploaded file in php spoody_goon Programming 2 05-10-2005 07:32 PM
Create alias or add to $PATH ryedunn Linux - Newbie 3 08-18-2004 10:42 AM

LinuxQuestions.org > Forums > Other *NIX Forums > Other *NIX

All times are GMT -5. The time now is 11:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration