|
|
#1 |
|
Prospect
Join Date: Apr 2007
Posts: 12
|
Multiple ways to create permanent aliases
On my mac, I have created some permanent aliases in the past, but I don't remember how. I can see them by typing
Code:
alias Code:
alias c='clear' alias ls='ls -lp' |
|
|
|
|
|
#2 |
|
Moderator
Join Date: Jun 2003
Location: Boulder, CO USA
Posts: 19,560
|
Assuming that you're using bash:
/etc/profile ~/.bash_profile ~/.bash_login ~/.profile For non-login shells: ~/.bashrc Also, it could be in any file of any name that one of the above files calls. Trevor
__________________
How to ask questions the smart way |
|
|
|
|
|
#3 |
|
Prospect
Join Date: Apr 2007
Posts: 12
|
Thanks for the reply. Yes, I am using bash. But of those files you listed, the only one that exists is ~/.profile. Are there any other places?
|
|
|
|
|
|
#4 |
|
All Star
Join Date: Jan 2004
Location: Limerick, PA
Posts: 693
|
In Lion, it seems like terminal doesn't load a fresh copy of .profile when the terminal
App is launched. That means that changes to .profile don't seem to take effect. |
|
|
|
|
|
#5 | |||||||||||||||||||||||
|
Triple-A Player
Join Date: May 2008
Location: Down by the river
Posts: 195
|
Copy your .profile to .bash_profile (cp .profile .bash_profile). Mine is read each and every time I use Termninal. |
|||||||||||||||||||||||
|
|
|
|
|
#6 |
|
MVP
Join Date: Apr 2008
Location: Berkeley CA USA
Posts: 1,016
|
Each time Terminal opens a new window, it launches a new instance of your default shell as an interactive login session. If your default shell is bash, that means it reads and executes the commands from /etc/profile (assuming it exists, as it should), and then looks for and executes one of ~/.bash_profile, ~/.bash_login, or ~/.profile. It only executes the first one of these that it finds, which can be perplexing if you have more than one of them. (In particular, it won't read ~/.profile if either of ~/.bash_profile or ~/.bash_login exists.) This is the way it's always been. It's not new with Leopard.
An interactive but non-login bash session invokes only You can force other files to be read. For example, your ~/.bash_login file could contain: if [ -r ~/.profile ] ; then . ~/.profile; fi if you want ~/.profile to be read even though ~/.bash_login is present. It's probably less confusing, though, to minimize the number of startup files you create. Put in ~/.bashrc the stuff you want in all interactive bash sessions, be they login or not, and put in ~/.bash_login the stuff that only applies to login shells. (For example, it's only at login time that you need to futz around with $PATH.) Then make ~/.bash_login invoke ~/.bashrc. ~/.profile is primarily for sh login shells, but bash will use it if the more specific ~/.bash* files can't be found. Non-interactive shells do not as a rule read any startup files. They inherit everything they need from the environment of their invoker. (Kinda has to be this way. A startup file is likely to invoke non-interactive shells, and you'd get into a horrible loop.) |
|
|
|
|
|
#7 | ||||||||||||||||||||||||||||||||||||||||||||||
|
Moderator
Join Date: Jun 2003
Location: Boulder, CO USA
Posts: 19,560
|
Yes, it could be in any file of any name that ~/.profile calls. Can we see your ~/.profile? Trevor
__________________
How to ask questions the smart way |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|
|
#8 | |||||||||||||||||||||||
|
Moderator
Join Date: Jun 2003
Location: Boulder, CO USA
Posts: 19,560
|
By the way, I agree with ganbustein above. Although having only a ~/.profile will work when you follow the rules, it's a sh shell file, not a bash file. My preferred method is a minimalist ~/.bash_profile that looks like this: Code:
#------------------------ # # $HOME/.bash_profile # #------------------------ source $HOME/.bashrc Trevor
__________________
How to ask questions the smart way |
|||||||||||||||||||||||
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|