|
|
Do aliases belong in .bashrc or .profile?
|
|
|
|
Fresh-Faced Recruit
Join Date: Jan 2000
Location: Oakland, CA, USA
Status:
Offline
|
|
I'm very new to all of this, so bear with me.
I have read in two different places two different things to do with your aliases in the bash shell. One says to put your aliases in the .profile. The other source indicates that all aliases belong in the ~/.bashrc file instead.
So, I've added my aliases to ~/.bashrc, and they don't work.
I've copied the same aliases to the .profile, and they work as directed. But I thought that .profile was for higher level commands, not user-specific commands.
Is this proper? Which source is correct? Or does it really matter as long as it works?
On an unrelated note, is there a bash equivalent to the rehash command from csh shells?
Thanks,
Michael
|
Le ver vert va vers le verre vert.
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Jan 2000
Location: Oakland, CA, USA
Status:
Offline
|
|
Further digging has discovered a bashrc file in the /etc directory. Does this file conflict with the ~/.bashrc file?
|
Le ver vert va vers le verre vert.
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Jan 2000
Location: Oakland, CA, USA
Status:
Offline
|
|
Today is a day of exploration:
I ran ps, and it showed me
Code:
PID TT STAT TIME COMMAND
421 p1 Ss+ 0:00.07 bash
1321 std S 0:00.50 -bash
Does this mean there are two shells running?
|
Le ver vert va vers le verre vert.
|
|
|
|
|
|
|
|
Senior User
Join Date: Oct 2000
Location: Midwest
Status:
Offline
|
|
mgymouse-
When you create a .bashrc file in your home directory, that is read instead of the /etc/bashrc file.
Using the Terminal, you are in a non-login interactive shell. Each Terminal window you opens is another of the same type of shell. These read .bashrc if it is present, /etc/bashrc if it is not.
~/.bash_profile, .bash_login, and .profile are looked for, in that order, when a bash login shell is started. When the first of the three is found, it is read and bash stops looking. A login interactive shell is an authenticated shell and this type of shell is used by the system for a variety of housekeeping, setup, configuration tasks. When you login to OS X, a login shell is started and the first of there files is read.
Here is my .bash_profile
Code:
export ANT_HOME=/usr/local/ant/apache-ant-1.6.1
export CATALINA_HOME=/Library/Tomcat
export JAVA_HOME=/Library/Java/Home
export CVSROOT=/usr/local/cvsrep
export PYTHONPATH=/Users/xxx/bin/py
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/bin:/Library/Tcl/bin:/Users/xxx/bin
PS1="\W $"
. .bashrc
You see the last line calls my .bashrc file. All of my path info is available to the system.
My .bashrc file
Code:
PROMPT_COMMAND='echo -ne "\033]0;${PWD/$HOME/~}\007"'
alias path='echo -e ${PATH//:/\\n}'
alias prj='cd /Volumes/Data/Projects'
alias lm='ls -la | more'
alias lt='ls -atrl | more'
alias ..='cd ..'
alias /='cd /'
alias dsk='cd ~/Desktop'
alias lcl='cd /usr/local'
alias jvd='cd ~/Documents/Java_code'
alias jvr='cd ~/Documents/Java_code/JavaRanch'
alias ls='ls -G'
shopt -s histappend
shopt -s cdspell
shopt -s cdable_vars
Info here is what I have set up for use in the Terminal or with X11.
OSXFAQ has a great multi part OS X Unix tutorial that is very comprehensive and one I that really helped me.
HTH
Craig
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status:
Offline
|
|
hnmmm.... I use TCSH and Fred Sanchez's method of setting that stuff, so mine are in:
~/Library/init/tcsh/aliases.mine
and the env vars go in:
~/Library/init/tcsh/environment.mine
|
signatures are a waste of bandwidth
especially ones with political tripe in them.
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Jan 2000
Location: Oakland, CA, USA
Status:
Offline
|
|
Thanks for the advice. I followed your instructions for the .bash_profile which passes on to the .bashrc and it all works well for me. I'll forego the .profile and using the /etc/bashrc file to set aliases.
I'm learning very slowly, but it's all really cool.
Thank you for your help,
Michael
|
Le ver vert va vers le verre vert.
|
|
|
|
|
|
|
|
Senior User
Join Date: Oct 2000
Location: Midwest
Status:
Offline
|
|
Good the hear. Just to clarify, if you create ~/.profile (or .~/bash_profile or ~/bash_input) the default /etc/profile will not be read by bash. You can enter 'cat /etc/profile' to list the contents of that file and use that to make certain you have are aware of the PATH info etc. that was included in the default file.
Craig
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|