All my systems are defaulted to KornShell (I just don't really care to use BASH) and terminals on all of them are configured as log in shells in Xfce (KDE is installed -- do like some of the utilities, don't like the overhead); matter of fact all shells are configured as log in shells no matter what window manger I use.
I do the prompt with a file,
/etc/profile.d/ksh.sh (which is simply an edited part of
/etc/profile):
Code:
#!/bin/sh
#
# Set the HOST environment variable
export HOST="`uname -n`"
# Set ksh93 visual editing mode:
if [ "$SHELL" = "/bin/ksh" ]; then
# VISUAL=emacs # ugh
# VISUAL=gmacs # double ugh
VISUAL=vi # ah, elegance
fi
# Set a default shell prompt:
#PS1='`hostname`:`pwd`# '
# Do these anyway in case sombody uses a different shell
if [ "$SHELL" = "/bin/pdksh" ]; then
PS1='! $ '
elif [ "$SHELL" = "/bin/ksh" ]; then
PS1='${HOST}-${USER}-${PWD}: '
elif [ "$SHELL" = "/bin/zsh" ]; then
PS1='%n@%m:%~%# '
elif [ "$SHELL" = "/bin/ash" ]; then
PS1='$ '
else
PS1='\u@\h:\w\$ '
fi
PS2='> '
export PS1 PS2
The above makes a terminal window prompt look like
Code:
fubar-trona-/home/trona:
and, because all systems are configured identically, I always know what box I'm on when connected with
ssh to any one (or all) of them; one keyboard to rule them all, baby.
I also have, in each user home directory, .
profile, .
kshrc and .
exrc. The
.profile sets "useful" environment variables specific to the individual user:
Code:
fubar-trona-/home/trona: cat .profile
# set up default columns and lines
COLUMNS=80
LINES=40
export COLUMNS LINES
# set up default group
GRPNAME=`groups | cut -d' ' -f1`
export GRPNAME
# set up a good-size history
HISTSIZE=1000
export HISTSIZE
# set up the ksh environment
ENV=${HOME}/.kshrc
export ENV
# set up CVSROOT
CVSROOT=:pserver:trona@fubar.com:/usr/local/cvsroot
export CVSROOT
# change the PATH a little
export PATH=.:${HOME}/bin:${PATH}
export INSTALL_BASE=${HOME}
export LLDATABASES=${HOME}/LifeLines:.
export LLPROGRAMS=.:/usr/local/share/lifelines
# make COLUMNS and LINES the screen size
eval `resize`
The
COLUMNS and
LINES are handy for
curses forms; default to 80x40 (from the Goode Olde Days, that) and updated by the
eval `resize` at the end; saves some trouble now and again. The other stuff are for compatibility with some specific work I do.
I also set, for me only, the current working directory as first on
${PATH} followed by my
${HOME}/bin; I'm well aware of the hazards of so doing and have been doing it for about 30 years and don't need any argument about it: It's my party and I'll cry if I want to.
~/.kshrc simply sets some aliases I like:
Code:
fubar-trona-/home/trona: cat .kshrc
alias lc='/usr/bin/clear; /bin/ls ${LS_OPTIONS} -aCF'
alias ll='/bin/ls ${LS_OPTIONS} -al'
alias cls='clear'
alias hi='history -${LINES}'
alias rs='eval `resize`'
And
~/.exrc simply sets defaults that I like for
vi:
Code:
fubar-trona-/home/trona: cat .exrc
set autoindent showmode showmatch
As far as I know,
${SHELL} gets set by
login (from the log in shell in
/etc/passwd) and is then used in
/etc/profile so I don't see any problem with that. All the admin accounts are
/bin/false (or special purpose like
shutdown and
halt, one or two others) and you're not supposed to be fiddling with those anyway so I don't see any problem there (you need to do some administration, you do it with
su - far as I know and if you don't know what you're doing you shouldn't ought to be doing it anyway, eh?).
Defining terminal windows as log in shell does no harm -- you execute
su -, you get root's environment. When you exit, you're back to your own environment (
su - forks and executes in a new shell and when it exits that environment is gone). Simply demonstrated with
Code:
fubar-trona-/home/trona: su -
Password:
fubar-root-/root: whence -v ntpq
ntpq is a tracked alias for /usr/sbin/ntpq
fubar-root-/root: ^D
fubar-trona-/home/trona: whence -v ntpq
-ksh: whence: ntpq: not found
Same thing happens if you
su - userid -- you get a forked-and-exec'd new shell, it is gone when you exit.
So, basically, I don't really see the problem with
/etc/profile -- especially if you add custom files in
/etc/profile.d, which, for example, would include things like
Apache Ant,
Apache Maven,
Apache Tomcat,
Java (
jdk.sh and
jdk.csh) and one that I add for the
Generic Mapping Tools,
gmt.sh, which sets environment variables for it -- that's what
/etc/proifle.d is for, no need to mess with the default
/etc/proifle (as in the Goode Olde Days when that was your only choice for system-wide settings).
Good thinking, but I'm not sure there's actually a problem.