Binded aliases not saving at terminal logout?

Gwailo

B.A. Economics (Hon)
Sorry if this is a dumb question, but when I issue an 'alias' command to, say, start PHP4 so i don't have to go through the whole thing; I log in as admin and type"

alias bootphp "sudo apxs -e -a -n php4 /etc/httpd/libexec/libphp4.so"

and then I issue the command 'bootphp' and it works normally, and also lists correctly in 'alias'.

BUT when I logout, my binded commands all disppear (the custom ones that is)... Doesn't that kind of defeat the putpose of binding long commands :)

What am I doing worng? Do I have to save the aliases somehow? All help appreciated thanks!
 
Yes, save the aliases. They're endangered, doncha' know. :D

You can set aliases to be set up when you log in. From a terminal window, in your home directory (where the terminal normally starts up) type 'pico .cshrc'

This will bring you into an easy editor, and it should say something like "new file" at the bottom of the screen.

Enter your aliases.
alias la 'ls -a'
alias foo 'some really long command with lots of -parameters -yay'

Press CTRL-O to save, verify that you do indeed want to save as .cshrc, then type CTRL-X to exit.

Close the terminal window, the open a new one. Your aliases should still be there.

HTH
 
By the way, that is not a typo -- you want .cshrc with no filename. The dot will be hidden from a normal 'ls' command, so to see it you need to say 'ls -a'. Or 'la' if you have aliases set up. :)

And this is all assuming that you are using the default shell for Mac OSX. If you didn't change anything, you're using tcsh.

If you did change to the bash shell, similar commands can be put into your .bashrc file. The alias looks a little different for bash, something like
alias la='ls -a'
or
set alias la='ls -a'
but it's been a while since I've used bash to know for sure. :)
 
Hey nkuvu,

It worked beautifully, hope you don't mind I used emacs instead of pico :)

Thanks for the quick help!:p
 
Back
Top