Subject: Re: Shell initialization
To: None <netbsd-help@netbsd.org>
From: Erich T. Enke <eenke@wheaton.edu>
List: netbsd-help
Date: 01/24/2000 21:46:55
For bash (but should work similarly for sh):

# aliases are only set if bash is interactive - this saves time
# $- returns a string containing the options the shell was invoked with.
# If 'i' is included, the shell is interactive.
if echo $- |grep i >/dev/null; then

	# Set up prompts how I like them (would have to be modified for sh)
	export MYTTY=`tty |sed 's:/dev/::'`
	export PS1="\n\d   \t\n[\#] \u@\h:$MYTTY:\w:\\$ "
	export PS2="\\$> "

	# If the .bash_aliases file exists, source it.  Of course you could
	# just put the aliases here, but if you have many aliases, it's
	# easier to manage in a separate file.
	[ -f ~/.bash_aliases ] && . ~/.bash_aliases

	fi
fi

Hope that helps,
Erich

In article <387C4FBF.AD9E4551@indanet-gmbh.de>,
Alexander Sorg <Alexander.Sorg@indanet-gmbh.de> wrote:
>
>"Marinier, M. Claude, G." wrote:
>> How does one setup the various shell initialization files? I have not
>> found much about this.
>Look in the manpage of the shell. There should be a description of the
>different startup-files.
>> 
>> I have one specific problem: some configure scripts fail because of my
>> 'ls' alias. I use sh and bash. The issue is what goes in the /etc/profile,
>> the ~/.bash_login (or ~/.profile), and the ~/.bashrc files.
>In the /etc/profile file goes global (for all users) stuff. The
>dot-files
>in the user dirs are of course user-specific.
>To prevent things like your ls-alias from interfering with scripts, you
>should write an if-claus in your .profile, so that these aliases are
>only assigned in interactive sessions. I just have an example how this
>is done in csh:
>#-------- csh example --------
>if ($?prompt) then
>        # An interactive shell -- set some stuff up
>        set filec
>        set history = 1000
>endif
>#-------- csh example --------
>I don't know yet enough about sh to translate it apropriately.
>Hope this helps.
>Have fun,
>   Alex.