Connecting Tech Pros Worldwide Help | Site Map

.profile command alias

  #1  
Old January 31st, 2009, 10:25 PM
bilibytes's Avatar
Familiar Sight
 
Join Date: Jun 2008
Location: Europe
Posts: 128
Hi,

i am using a unix system and have made a .profile file to declare custom commands.
I did this by typing in that file functions like this:

Expand|Select|Wrap|Line Numbers
  1. showAllFiles(){
  2.     defaults write com.apple.finder AppleShowAllFiles $1
  3.     killall Finder
  4. }
where $1 can be set to true or false by calling this alias like this:

~user$: showAllFiles true

but now i want to be able to create commands with multiple parameters but i don't know how to do it, i would like something like the following:

Expand|Select|Wrap|Line Numbers
  1. cpFileToHtdocs(){
  2. sudo cp -i /Users/user/Documents/Projects/applicationX/code/$1
  3. /usr/local/apache2/htdocs/applicationX/$2
  4. }
i would like to be able to specify two different parameters for that command like this:

~user$: cpFileToHtdocs /from/path /to/other/path

/from/path => $1

/to/other/path => $2


if you know how to do that, i would be very pleased to hear about it,

Thank you very much

Regards
  #2  
Old February 1st, 2009, 05:55 PM
Nepomuk's Avatar
Moderator
 
Join Date: Aug 2007
Location: Germany
Posts: 2,468

re: .profile command alias


And the way you posted here doesn't work?

I guess, me might need some more information - what shell are you using for example? (You should be able to get that information by calling echo $SHELL, if your Unix is anything like Linux - which it probably is.) From what I've read, it might well be korn, but it's better to make sure. If it is korn, this tutorial (especially Listing 15) should be helpful.

Greetings,
Nepomuk
  #3  
Old February 1st, 2009, 06:22 PM
bilibytes's Avatar
Familiar Sight
 
Join Date: Jun 2008
Location: Europe
Posts: 128

re: .profile command alias


Quote:
Originally Posted by Nepomuk View Post
And the way you posted here doesn't work?

I guess, me might need some more information - what shell are you using for example? (You should be able to get that information by calling echo $SHELL, if your Unix is anything like Linux - which it probably is.) From what I've read, it might well be korn, but it's better to make sure. If it is korn, this tutorial (especially Listing 15) should be helpful.

Greetings,
Nepomuk
Hi thanks for replying!

no, i'm using mac os x with GNU bash shell.
korn is not preinstalled on mac.

ok now that I know my shell name, i'll google to find it out

Thankyou again

regards

bilibytes
  #4  
Old February 1st, 2009, 06:45 PM
bilibytes's Avatar
Familiar Sight
 
Join Date: Jun 2008
Location: Europe
Posts: 128

re: .profile command alias


here is the answer:

http://tldp.org/LDP/abs/html/complexfunct.html
  #5  
Old February 1st, 2009, 11:35 PM
Nepomuk's Avatar
Moderator
 
Join Date: Aug 2007
Location: Germany
Posts: 2,468

re: .profile command alias


Glad that you got it working!

Greetings,
Nepomuk

EDIT: As this is a Mac OS X question and we have a Mac OS X Forum, I'll move it there, but leave a redirect in the Unix / Linux Forum.
Reply