Subject: More Shell Things
To: None <netbsd-help@netbsd.org>
From: John <john@icculus.net>
List: netbsd-help
Date: 07/31/2000 13:22:12
Hello. This doesn't really seem to fit into any of the other lists, so
please tell me if I should send it elsewhere...
NetBSD is great, but in my opinion the default shell setups aren't, erm,
spiffy enough :) So, I have created some login scripts to modify their
behavior. Hopefully they will be found useful enough to make their way
into a future release. They basically just set the prompt, xterm title
if $TERM==xterm*, and turn on a few useful features. The best place for
them would be in /etc/skel I would think. But, if they are put into the
/etc/profile and /etc/csh.login, some additional code should probably be
added to deal with uid root.
Here is .profile:
export HOSTNAME="`hostname`"
if [ "$SHELL" = "/bin/sh" ]; then
PS1="$HOSTNAME$ "
set -E # Emacs command edit mode, switch to -V
for vi
elif [ "$SHELL" = "/bin/ksh" ]; then
case $TERM in
xterm*)
PS1='^[]0;$HOSTNAME: $PWD^G! $HOSTNAME:$PWD$ '
#PS1='^[]0;$HOSTNAME: ${PWD##${HOME}/}^G! $HOSTNAME:$PWD$ '
;;
*)
PS1='! $HOSTNAME:$PWD$ '
#PS1='! $HOSTNAME:${PWD##${HOME}/}$ '
;;
esac
set -o emacs # emacs command edit mode
bind '^I'=complete-list # tab completion
elif [ "$SHELL" = "/usr/pkg/bin/bash" ]; then
case $TERM in
xterm*)
PS1='\[\033]0;\h: \w\007\]\h:\w\$ '
;;
*)
PS1='\h:\w\$ '
;;
esac
fi
And here is .login:
setenv HOSTNAME "`hostname`"
if ("$SHELL" == "/bin/csh") then
switch ($TERM)
case "xterm*":
set prompt = "! $HOSTNAME% "
alias cd 'cd \!*; echo -n "^[]0;${HOSTNAME}: ${cwd}^G"'
breaksw
default:
set prompt = "! $HOSTNAME% "
breaksw
endsw
set filec # turn on esc completion
#set notify # personal preference, read man csh
set history = 100 # turn on history and set length
else if ("$SHELL" == "/usr/pkg/bin/tcsh") then
switch ($TERM)
case "xterm*":
set prompt = "%{\033]0;%m: %~\007%}! %m:%~%# "
breaksw
default:
set prompt = "! %m:%~%# "
breaksw
endsw
set autolist # generate lists for completion
#set notify # personal preference, read man tcsh
#set rmstar # prompt on rm *
endif
Note that for the csh and ksh xterm title setting lines, ^[ and ^G are
really the ESC and BEL characters respectively. These can be entered in
emacs using C-q ESC and C-q C-g. Both of these scripts were developed
under 1.4.2, but should have no porting problems. I included the code
to configure tcsh and bash since those are (I would assume) the two
shells people are most likely to add to their systems. I also have a
.rcrc for the plan9 rc shell if anyone's interested. If many people are
using zsh these days, I could work something up for it too.
--
JohnM
john@icculus.net