Date: Wed, 21 Apr 2010 20:30:59 -0400 (EDT) From: vogelke+unix@pobox.com (Karl Vogel) To: questions@freebsd.org Subject: Re: multishell user profile Message-ID: <20100422003059.B61A7BDF4@bsd118.wpafb.af.mil> In-Reply-To: <4BCEAEDC.8000700@locolomo.org> (message from Erik Norgaard on Wed, 21 Apr 2010 09:53:00 %2B0200) References: <4BCEAEDC.8000700@locolomo.org>
next in thread | previous in thread | raw e-mail | index | archive | help
>> On Wed, 21 Apr 2010 09:53:00 +0200,
>> Erik Norgaard <norgaard@locolomo.org> said:
E> I need to create a user profile that works in different shells,
E> particularly bash, csh and ksh. It seems that these does not read the
E> same files and/or in the same order. So, how do I configure the shell
E> profiles without configuring each shell separately?
The two things that bite me the most often when switching shells are
environment variables and aliases. I keep most of my environment stuff
in a single file ($HOME/.envrc) with entries like this:
# Local time for RCS date information
RCSINIT "-zLT"
# Default file browser.
PAGER "less"
A small perl script converts this into sh- or csh-style commands, so I
can just source the appropriate file from .bashrc or .tcshrc or whatever:
me% cat ~/.envrc.sh
# Local time for RCS date information
RCSINIT="-zLT"; export RCSINIT
# Default file browser.
PAGER="less"; export PAGER
me% cat ~/.envrc.csh
# Local time for RCS date information
setenv RCSINIT "-zLT"
# Default file browser.
setenv PAGER "less"
Aliases are annoying because the syntax is inconsistent, so I only use
those for inside-the-shell stuff like job control. Small ~/bin scripts
handle things like using "dir" instead of "ls -lF":
#!/bin/sh
#<dir: long directory listing; skip colors if running script/saveon.
case "$SAVEON" in
"") opt='--color=auto' ;;
*) opt='' ;;
esac
unset BLOCK_SIZE # throws off the results for GNU ls.
exec /usr/local/bin/ls -lF $opt ${1+"$@"}
exit 1
Put the invariant stuff in the system startup files. Something like
this in /etc/profile would handle a general bash/ksh/sh environment:
test -f "$HOME/.envrc.sh" && . $HOME/.envrc.sh
--
Karl Vogel I don't speak for the USAF or my company
If someone has a mid-life crisis while playing hide & seek,
does he automatically lose because he can't find himself? --Steven Wright
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100422003059.B61A7BDF4>
