My Shell Setup Suite

John Hurst

Version 1.8.1

20101213:170646

This document defines and describes the suite of programs used to create my shell working environment on the range of machines that I use.

Table of Contents

1 Introduction
2 Literate Data
3 The Profile file .bash profile
3.1 Who are we?
3.2 Where are we?
3.3 Set Environment Variables
3.3.1 Set the PATH variable
3.4 Set Background Colour
4 The Set Machine file
5 The Bash Resource Control file .bashrc
5.1 Define aliases
5.2 Define the shell prompt
5.3 Determine if Primary Login
5.4 The bash-prompt file
6 .texrc The TeX Resource Control file
7 .sgmlrc The SGML Resource Control file
8 Logging out: .bash_logout
9 Window Colours
10 The Makefile
11 Indices
11.1 Files
11.2 Chunks
11.3 Identifiers


1. Introduction

This document describes the files used to set up the appropriate working environment for using the bash shell. They are intensely personal, and anyone reusing this document for their own purposes will also certainly want to modify this document.

Permission is given to reuse this document, provided that the source is acknowledged, and that any changes are noted in the documentation.

The document is in the form of a literate program, and generates all files necessary to maintain the working environment, including a Makefile.

These files have been edited from equivalent tcsh originals, but not all features of that shell have been mirrored in here.

2. Literate Data

This message gets used in a number of places to ensure that all modifications are focussed through this document.

<edit warning 2.1> =
DO NOT EDIT this file! see $HOME/Computers/Sources/Setup/setup.xlp instead
Chunk referenced in 3.1 5.1 5.12 6.1

3. The Profile file .bash profile

The .bash_profile file is executed automatically by login shells. It has the responsibility to set the path (and other variables), run the .bashrc file (because a login shell doesn't do that automatically), and initialize the prompt with an explicit call to bash-prompt. I also worry about the initial login shell, since that has to do slightly different things (such as setting window title bars, and clearing up when logging out).

".bash_profile" 3.1 =
#<edit warning 2.1> # version=<current version .1>, <current date .2> #echo "start .bash_profile" <determine who we are 3.2> <determine where we are 3.3,3.4,3.5> <record where we are 3.7> <bash: set variables 3.8> stty kill ^U erase ^? intr ^C source $HOME/.bashrc if [ $SHLVL -gt 0 ] ; then $HOME/bin/bash-prompt fi #echo "end .bash_profile"

3.1 Who are we?

<determine who we are 3.2> =
TZ='Australia/Melbourne'; export TZ if [ -x /usr/bin/whoami ] ; then user=`/usr/bin/whoami` elif [ -x /usr/local/bin/whoami ] ; then user=`/usr/local/bin/whoami` else echo "$0: Unable to determine username, no /usr/bin/whoami" fi
Chunk referenced in 3.1

We often need to know in this script whether we are logging in as ajh or as root. This code chunk sets the global variable $user appropriately, or dies.

3.2 Where are we?

<determine where we are 3.3> =
if [ -x /bin/hostname ] ; then HOSTNAME=`/bin/hostname` else echo "$0: Unable to determine machine name, no /bin/hostname" fi export HOSTNAME
Chunk referenced in 3.1 5.1
Chunk defined in 3.3,3.4,3.5

Crucial to the whole rigmarole of setting things up is knowing on what machine we are running. hostname is our friend here. If there is no hostname, then we are in deep do-dos. Call the iamhere script to record this location.

<determine where we are 3.4> =
if [ -x /bin/expr ] ; then EXPR=/bin/expr else EXPR=/usr/bin/expr fi
Chunk referenced in 3.1 5.1
Chunk defined in 3.3,3.4,3.5

For some strange reason, the expr program resides in a different place on Ubuntu systems. Find the right one.

<determine where we are 3.5> =
HOST=`hostname -s` export HOST
Chunk referenced in 3.1 5.1
Chunk defined in 3.3,3.4,3.5

The upshot is to set HOST as an abbreviated form of HOSTNAME, that is, without any domain qualification. Do this by extracting the prefix of ".". Note the new version of this, using the -s flag to hostname. It pays to read the manual! The old version follows, commented out.

<determine where we are - expr 3.6> =
HOST=`$EXPR $HOSTNAME : '\([^.]*\)'` export HOST
<record where we are 3.7> =
$HOME/bin/iamhere
Chunk referenced in 3.1

3.3 Set Environment Variables

The variables that we set are

ASSOCDB
Defines the absolute pathname to the assoc program's database file. It is currently set to /home/ajh/assoc/files, and set in <set sundry environment variables >.
HEADING
Filename to record what is displayed at the head line of the window. This is modified by process number to ensure that each window is handled independently. See scrap <set heading 5.13>.
HOST
The leading word (non-`.' characters) of the full hostname. For example, if HOSTNAME gives central.cs.monash.edu.au, return just central. See scrap <determine where we are 3.3,3.4,3.5>.
MANPATH
The search path for man pages.
PATH
The search path for commands and binaries. See scrap <set paths on all machines 3.9,3.30>.
PILOTPORT
The port used by the pilot software, and set in <set sundry environment variables 3.33>
RSYNC_RSH
The rsh protocol to be used by rsync, currently set to ssh, and set in <set sundry environment variables 3.33>.
SERVER
The name of the server machine.
BGCOLOUR
The background colour for this machine (see section Window Colours)
PYTHONPATH
The path to search for Python libraries.
ARARAT
The qualified domain name to reach ararat from the current platform.
BALLARAT
The qualified domain name to reach ballarat from the current platform.
BITTERN
The qualified domain name to reach bittern from the current platform.
MURTOA
The qualified domain name to reach murtoa from the current platform.
RAINBOW
The qualified domain name to reach rainbow from the current platform.
<bash: set variables 3.8> =
<set sundry environment variables 3.33> <set paths on all machines 3.9,3.30> if [ $SHLVL -le 1 ] ; then <do root related login things here 3.31> else <do non-root related login things here 3.32> fi if [ -f $HOME/.texrc ] ; then source $HOME/.texrc fi if [ -f $HOME/.set_colours.sh ] ; then source $HOME/.set_colours.sh fi
Chunk referenced in 3.1
echo $PATH

The sundry variables are set first, since some of them may be used to set the path variable.

3.3.1 Set the PATH variable

Note that the paths are established in increasing order of precedence, that is, the last paths defined are found first.

The machines ararat, ballarat, bendigo, bittern, dimboola, clematis, murtoa and rainbow are all set in like fashion, as they all run Mac OS X (even tho' bittern, clematis, dimboola and murtoa are Intel Macs).

<set paths on all machines 3.9> =
PATH="/bin" # base path case $HOST in ararat | its--roaming* | w-cl | dhcp7-218*) <set path for ararat 3.10> ;; ballarat ) <set path for ballarat 3.11> ;; bendigo ) <set path for bendigo 3.12> ;; bittern | dyn* | bsit-roaming* | roaming-* ) <set path for bittern 3.13> ;; bruce ) <set path for nexus 3.22> ;; clematis ) <set path for clematis 3.16> ;; central ) <set path for central 3.14> ;; cerg* | vm-cerg* ) <set path for cerg 3.15> ;; dimboola ) <set path for dimboola 3.17> ;; garedelyon ) <set path for garedelyon 3.18> ;; hawthorn) <set path for hawthorn 3.19> ;; meconopsis ) <set path for meconopsis 3.20> ;; murtoa ) <set path for murtoa 3.21> ;; nexus ) <set path for nexus 3.22> ;; quorn ) <set path for quorn 3.23> ;; rainbow ) <set path for rainbow 3.24> ;; eregnans | eregnans.ajhurst.org | regnans* ) <set path for eregnans 3.25> ;; tarma ) <set path for nexus 3.22> ;; sng* ) <set path for sng 3.26> ;; *) echo "$0: Using defaults to set path for $HOST" <set path for defaults 3.29> ;; esac export PATH
Chunk referenced in 3.8
Chunk defined in 3.9,3.30

dhcp7-218 was added during my OSP at Swinburne, since that was the hostname automatically generated by the DHCP connection.

<set path for ararat 3.10> =
<set common path for MacOSX systems 3.27>
Chunk referenced in 3.9
<set path for ballarat 3.11> =
<set common path for MacOSX systems 3.27>
Chunk referenced in 3.9
<set path for bendigo 3.12> =
<set common path for MacOSX systems 3.27>
Chunk referenced in 3.9
<set path for bittern 3.13> =
<set common path for MacOSX systems 3.27> PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}" PATH="/home/ajh/bin/EXIFutilsOSX2.7:${PATH}" # EXIFutils Installation
Chunk referenced in 3.9
<set path for central 3.14> =
<set common path for Linux systems 3.28>
Chunk referenced in 3.9
<set path for cerg 3.15> =
<set common path for Linux systems 3.28>
Chunk referenced in 3.9
<set path for clematis 3.16> =
<set common path for MacOSX systems 3.27>
Chunk referenced in 3.9
<set path for dimboola 3.17> =
<set common path for MacOSX systems 3.27>
Chunk referenced in 3.9
<set path for garedelyon 3.18> =
<set common path for Linux systems 3.28>
Chunk referenced in 3.9
<set path for hawthorn 3.19> =
<set common path for Linux systems 3.28> PATH="$BKIT:$PATH" # B Toolkit
Chunk referenced in 3.9
<set path for meconopsis 3.20> =
<set common path for MacOSX systems 3.27>
Chunk referenced in 3.9
<set path for murtoa 3.21> =
<set common path for MacOSX systems 3.27> PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}" PATH="/home/ajh/bin/EXIFutilsOSX2.7:${PATH}" # EXIFutils Installation
Chunk referenced in 3.9
<set path for nexus 3.22> =
PATH="/bin:/usr/bin" # base path PATH="/sbin:/usr/sbin:$PATH" # system binaries PATH="/usr/X/bin:$PATH" # X11 binaries PATH="/usr/monash/bin:$PATH" # local binaries PATH="/usr/ucb:$PATH" # local binaries PATH="/usr/etc:$PATH" # local system binaries PATH="/usr/monash/tex/bin:$PATH" # local (old) tex binaries PATH="/usr/monash/tetex/bin:$PATH" # local tex binaries PATH="/usr/monash/X11/bin:$PATH" # local X11 binaries PATH="/usr/monash/mh:$PATH" # mh binaries PATH="/usr/monash/contrib/bin:$PATH" # contributed binaries PATH="/usr/monash/gnu/bin:$PATH" # gnu binaries PATH="$HOME/bin:$PATH" # personal binaries PATH="$BKIT:$PATH" # B-Toolkit binaries PATH=".:$PATH" # cwd binaries
Chunk referenced in 3.9
<set path for quorn 3.23> =
<set common path for MacOSX systems 3.27>
Chunk referenced in 3.9
<set path for rainbow 3.24> =
PATH="/bin:/usr/bin" # base path PATH="/usr/local/bin:$PATH" # local binaries PATH="/usr/bin/X11:$PATH" # X11 binaries PATH="/sbin:/usr/sbin:$PATH" # system binaries PATH="/usr/local/sbin:$PATH" # local system binaries PATH="$HOME/bin:$PATH" # personal binaries PATH=".:$PATH" # cwd binaries
Chunk referenced in 3.9
<set path for eregnans 3.25> =
<set common path for Linux systems 3.28>
Chunk referenced in 3.9
<set path for sng 3.26> =
PATH="/usr/bin:$PATH" # user binaries PATH="$BKIT:$PATH" # B Toolkit PATH="/usr/local/bin:$PATH" # local binaries PATH="/usr/openwin/bin:$PATH" # X11 binaries PATH="$HOME/bin:$PATH" # personal binaries and scripts PATH=".:$PATH" # cwd binaries
Chunk referenced in 3.9
<set common path for MacOSX systems 3.27> =
if [ $user = ajh ] ; then PATH="/sbin:$PATH" # system binaries PATH="/usr/sbin:/usr/bin:$PATH" # user binaries PATH="/usr/local/bin:$PATH" # local binaries PATH="/usr/X11R6/bin:$PATH" # X11 binaries PATH="$HOME/bin:$PATH" # personal binaries PATH="$HOME/bin/macosx:$PATH" # personal system binaries PATH="/sw/bin:$PATH" # fink binaries PATH="/sw/sbin:$PATH" # fink system binaries PATH="$HOME/Pictures/bin:$PATH" # picture scripts PATH=".:$PATH" # cwd binaries elif [ $user = root ] ;then PATH="/sbin:$PATH" # system binaries PATH="/usr/sbin:/usr/bin:$PATH" # user system and binaries PATH="/usr/local/bin:$PATH" # local binaries PATH="/usr/local/sbin:$PATH" # local system binaries PATH="/usr/X11R6/bin:$PATH" # X11 binaries PATH="/sw/bin:$PATH" # fink binaries PATH="/sw/sbin:$PATH" # fink system binaries else echo "Unknown user $user" exit 1 fi alias python=/sw/bin/python2.6 # make python default to 2.6
Chunk referenced in 3.10 3.11 3.12 3.13 3.16 3.17 3.20 3.21 3.23 3.29
<set common path for Linux systems 3.28> =
PATH="/usr/sbin:/sbin:$PATH" # system binaries PATH="/usr/bin:$PATH" # user binaries PATH="/usr/X11R6/bin:$PATH" # X11 binaries PATH="/usr/local/bin:$PATH" # local binaries PATH="/usr/bin/mh:$PATH" # mh binaries PATH="$HOME/bin:$PATH" # personal binaries PATH="$HOME/bin/i386-pc-linux:$PATH" # personal system binaries PATH="$HOME/bin/i586:$PATH" # personal system binaries PATH=".:$PATH" # cwd binaries
Chunk referenced in 3.14 3.15 3.18 3.19 3.25
<set path for defaults 3.29> =
<set common path for MacOSX systems 3.27>
Chunk referenced in 3.9

The defaults settings assume that we are on a laptop (ararat, but either no hostname, or foreign hostname), so that we go for the standard Mac OS X settings.

<set paths on all machines 3.30> =
Chunk referenced in 3.8
Chunk defined in 3.9,3.30

Now empty, but kept for future use.

<do root related login things here 3.31> =
echo "Welcome!" touch $HOME/.online
Chunk referenced in 3.8
<do non-root related login things here 3.32> =
: # do nothing at this stage
Chunk referenced in 3.8

Set the environment variable RSYNC_RSH, which defines the shell transport for rsync as the secure shell ssh.

<set sundry environment variables 3.33> =
export ASSOCDB=/home/ajh/Computers/assoc/files export RSYNC_RSH="ssh -2 " <set SERVER environment variable 3.44> **** Chunk omitted! <set LD LIBRARY PATH environment variable 3.45> <set MANPATH environment variable 3.46> <set XMLLIB environment variable 3.47> case $HOST in ararat|ballarat|bendigo|clematis|dimboola|rainbow|meconopsis|w-cl) <set env vars for MacOSX 3.39> ;; bittern | dyn* | its-roaming* | bsit-roaming* | roaming-*) <set env vars for MacOSX 3.39> ;; cerg* | vm-cerg* ) <set env vars for cerg 3.37> ;; dhcp7-218*) <set env vars for MacOSX 3.39> export HTTP_PROXY=proxy-lvs.cc.swin.edu.au:8000 export FTP_PROXY=proxy-lvs.cc.swin.edu.au:8000 ;; hawthorn) <set env vars for hawthorn 3.35> ;; murtoa) <set env vars for MacOSX 3.39> <set environment for ciao prolog 3.34> ;; central*) <set env vars for central 3.36> ;; sng*) <set env vars for sng 3.40> ;; garedelyon) <set env vars for eregnans 3.38> ;; eregnans* | regnans* ) <set env vars for eregnans 3.38> ;; *) echo "$0: Using defaults to set environment variables for $HOST" <set env vars for MacOSX 3.39> ;; esac
Chunk referenced in 3.8

dhcp7-218 is the machine id allocated at Swinburne (study leave, 2005). It can be removed post 31 Dec 2005.

<set environment for ciao prolog 3.34> =
if [ -f /usr/local/lib/ciao/DOTprofile ]; then . /usr/local/lib/ciao/DOTprofile fi
Chunk referenced in 3.33

Currently, only murtoa is set up for ciao prolog

<set env vars for hawthorn 3.35> =
export PILOTPORT=/dev/ttyS1 export BKIT=/usr/local/BToolkit/BToolkit/BKIT <set env vars for CVS on hawthorn 3.42>
Chunk referenced in 3.33
<set env vars for central 3.36> =
Chunk referenced in 3.33
<set env vars for cerg 3.37> =
Chunk referenced in 3.33
<set env vars for eregnans 3.38> =
Chunk referenced in 3.33
<set env vars for MacOSX 3.39> =
<set the perl library for MacOSX systems 3.41> <set env vars for CVS on MacOSX systems 3.43> export PYTHONPATH=/home/ajh/Computers/python:/usr/local/lib/python
Chunk referenced in 3.33
<set env vars for sng 3.40> =
export BKIT=/usr/local/BToolkit/BKIT
Chunk referenced in 3.33
<set the perl library for MacOSX systems 3.41> =
export PERL5LIB=/sw/lib/perl5/darwin
Chunk referenced in 3.39
<set env vars for CVS on hawthorn 3.42> =
export CVS_RSH=ssh export CVSROOT=/var/cvsroot
Chunk referenced in 3.35
<set env vars for CVS on MacOSX systems 3.43> =
export CVS_RSH=ssh export CVSROOT=hawthorn:/var/cvsroot
Chunk referenced in 3.39
<set SERVER environment variable 3.44> =
/bin/expr ${DISPLAY:-unset} : ".*\:[1-9][0-9]*\.0" >/dev/null if [ $? -eq 0 ] ; then case $HOST in ararat*|ballarat*|bendigo*|bittern*|clematis*|dimboola*|murtoa*) ;; bsit-roaming*) ;; central*) SERVER=indy03.cs.monash.edu.au ;; indy03*) SERVER=central ;; hawthorn*) SERVER=hawthorn.csse.monash.edu.au ;; ajh.id.au) SERVER=ajh.id.au ;; eregnans|ajhurst.org) SERVER=ajhurst.org ;; *) echo "$0: No case branch to set SERVER environment variables for $HOST" ;; esac else SERVER=$HOST fi export SERVER
Chunk referenced in 3.33

Now work out what value to assign to SERVER. This is currently kludged, since there is no direct way of knowing what is at the other end of the wire for remote connections. We assume that at home we are using central, and at work we are using hawthorn.

We pick up whether the DISPLAY variable ends with a non-zero window number. This is used by ssh to indicate a remote server. If DISPLAY does indicate a remote server, we use the value of HOST to select the complementary machine (indy03 for host central, and vice versa) and assign that to SERVER. If DISPLAY indicates a local server, then just use the value of HOST as the value of SERVER.

<set LD LIBRARY PATH environment variable 3.45> =
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/sgml/xml4c2_3_1/lib
Chunk referenced in 3.33
<set MANPATH environment variable 3.46> =
export MANPATH="/usr/share/man:/usr/X11R6/man"
Chunk referenced in 3.33
<set XMLLIB environment variable 3.47> =
export XMLLIB=".:/home/ajh/lib/xml:/home/ajh/web/trains" export XML_CATALOG_FILES="/home/ajh/etc/xml/catalog"
Chunk referenced in 3.33

3.4 Set Background Colour

".set_colours.sh" 3.48 =
#DO NOT EDIT this file! see $HOME/Computers/Sources/Setup/setup.xlp instead #echo "start .set_colours.sh" if [ "X$HOST"="X" ] ; then if [ -x /bin/hostname ] ; then HOSTNAME=`/bin/hostname` else echo "$0: Unable to determine machine name, no /bin/hostname" fi export HOSTNAME HOST=`$EXPR $HOSTNAME : '\([^.]*\)'` export HOST fi case $HOST in ararat* | its--roaming | dhcp7-218* | bsit-roaming* ) export BGCOLOUR=<bg-colour-ararat 9.2> ;; ballarat*|meconopsis) export BGCOLOUR=<bg-colour-ballarat 9.12> ;; bendigo*) export BGCOLOUR=<bg-colour-bendigo 9.5> ;; bittern* | dyn-* | roaming-*) export BGCOLOUR=<bg-colour-bittern 9.8> ;; clematis*) export BGCOLOUR=<bg-colour-clematis 9.17> ;; dimboola*) export BGCOLOUR=<bg-colour-dimboola 9.9> ;; murtoa*) export BGCOLOUR=<bg-colour-murtoa 9.1> ;; rainbow*) export BGCOLOUR=<bg-colour-rainbow 9.11> ;; eregnans* | regnans* ) export BGCOLOUR=<bg-colour-eregnans 9.7> ;; *) echo "$0: No case branch to set BGCOLOUR for $HOST" esac #echo "end .set_colours.sh"

4. The Set Machine file

"setmachine" 4.1 =
#!/bin/bash machine=$1 mv $HOME/.xinitrc $HOME/.xinitrc.sav ln -s $HOME/Computers/Parameters/Xinitrc.$machine $HOME/.xinitrc mv $HOME/.xdefaults $HOME/.xdefaults.sav ln -s $HOME/Computers/Parameters/Xdefaults.$machine $HOME/.xdefaults

This simple little script ensures that the X initialization and default files point to the right place.

5. The Bash Resource Control file .bashrc

The .bashrc file is read every time a bash shell is started. For interactive shells, we need to set the aliases and the prompt.

".bashrc" 5.1 =
#<edit warning 2.1> # version=<current version .1>, <current date .2> #echo "start .bashrc" <determine where we are 3.3,3.4,3.5> <bashrc: setup aliases 5.2,5.3> <bashrc: set the prompt 5.10> <determine if primary login 5.11> #cd $HOME #echo "end .bashrc"

5.1 Define aliases

<bashrc: setup aliases 5.2> =
alias a='alias' alias d='dirs' alias fbak="find . \( -name '*~*' -o -name '*.bak' \) -print" alias frmbak="find . \( -name '*~*' -o -name '*.bak' \) -print -exec rm {} \;" alias h='history' alias hangups='fgrep "Modem hangup" /var/log/messages' alias l='ls -F' alias ll='ls -Fltr' alias m='more' alias rmbak='rm .*~* *~* *-lw* *% .*% *# ,* *.bak .*.bak 2>/dev/null' alias top='top -o cpu' alias ec='emacsclient -n' function up () { cd ..; } #function + () { function mypushd () { if [ "X$1" = "X" ] ; then pushd else pushd "$1" fi;}{Note 5.2.1} eval alias '+'=mypushd function mypopd () { popd; } eval 'function - () { popd; }' #source /home/ajh/bin/makeminusalias.sh #eval alias '\-'=mypopd
Chunk referenced in 5.1
Chunk defined in 5.2,5.3
{Note 5.2.1}
Note that the argument to pushd in the definition of + must be quoted, to avoid problems with directories names containing embedded spaces. But we also have to be careful with empty parameters!

Note the bizarre behaviour here. I cannot define a function '+', since '+' is not a valid identifier. But '-' is. On the other hand, I cannot make an alias for '-', but I can for '+'. Work that one out.

At least, all's well that ends well.

20091020:094011 No, not really. While the script works as such, the Makefile barfs when it tries to execute (source?) the offending eval function line. Got no further clues at this stage.

<bashrc: setup aliases 5.3> =
function tsize () { stty -a |sed -n '/rows.*columns/ s/.*\(rows[^;][^;]*;[^;][^;]*\);.*/\1/p'; } function killer () { kill -KILL $(ps xc | grep -wi "$*" | awk '{print $1}'); } case $HOST in bittern | dimboola | dyn* | roaming-* | its--roaming*) <specific aliases for macosx snow leopard 5.9> ;; bendigo | murtoa | dyn* ) <specific aliases for macosx leopard 5.8> ;; ararat|ballarat|clematis|rainbow|meconopsis*) <specific aliases for macosx tiger 5.7> ;; hawthorn) <specific aliases for hawthorn 5.4> ;; eregnans) <specific aliases for eregnans 5.5> ;; nexus*) <specific aliases for nexus 5.6> ;; *) ;; esac
Chunk referenced in 5.1
Chunk defined in 5.2,5.3
<specific aliases for hawthorn 5.4> =
alias xdvil='xdvi -paper a4r -geom 1173x830-0+0'
Chunk referenced in 5.3
<specific aliases for eregnans 5.5> =
alias tlwww='tail -f /var/log/apache2/error.log' alias tlxml='tail -f /home/ajh/local/$HOST/xmlerror.log'
Chunk referenced in 5.3
<specific aliases for nexus 5.6> =
alias tlwww="tail -f /u/web/csse/logs/error_log" alias tlxml="tail -f /u/homes1/ajh/xmlerror.log"
Chunk referenced in 5.3
<specific aliases for macosx tiger 5.7> =
alias tlwww='tail -f /var/log/httpd/error_log' alias tlxml='tail -f /home/ajh/local/$HOST/xmlerror.log'
Chunk referenced in 5.3
<specific aliases for macosx leopard 5.8> =
alias tlwww='tail -f /var/log/apache2/error_log' alias tlxml='tail -f /home/ajh/local/$HOST/xmlerror.log' alias tllocal='tail -f /home/ajh/local/localhost/xmlerror.log'
Chunk referenced in 5.3
<specific aliases for macosx snow leopard 5.9> =
alias tlwww='tail -f /var/log/apache2/error_log' alias tlxml='tail -f /Users/ajh/local/$HOST/xmlerror.log' alias tllocal='tail -f /Users/ajh/local/localhost/xmlerror.log'
Chunk referenced in 5.3

5.2 Define the shell prompt

I like the prompt to show what directory I'm in, as well as the usual login and machine names. Throw in the history number for good measure. But don't set the prompt command if we are in the primary login shell, since it fouls up the window title and/or prompt.

<bashrc: set the prompt 5.10> =
if [ X$HOST = "Xfangorn" ] ; then USER=$LOGNAME; export USER fi PS1='\n$USER@$HOST $PWD \! $ ' if [ ${SHLVL} -ne 0 ] ; then PROMPT_COMMAND='~ajh/bin/bash-prompt' fi
Chunk referenced in 5.1

This shell script is because bash does not have the equivalent of cwdcmd that tcsh has. So we set up the PROMPT_COMMAND variable to execute this script, which looks at the current heading, the current directory, and sees whether an explicit repainting of the window title bar is necessary.

5.3 Determine if Primary Login

This code used to be called from .bash_profile, but key environment variables were not set at this stage. Hence it is now invoked in .bashrc.

<determine if primary login 5.11> =
if [ X$TERM = X -o X$TERM = Xlinux ] ; then export LOGINLVL=0 else export LOGINLVL=1 fi
Chunk referenced in 5.1

We need to know if we are in the primary login shell. This may be different for various machines, since some may be xdm driven, while others just give a tty login. The outcome of this code is to set the variable LOGINLVL to 0 if we are at the primary login level, 1 otherwise.

5.4 The bash-prompt file

The bash-prompt file does cool things like set the window title to the path name of the current directory. It is programmed as a separate executable file, due to bash's idiosyncracies (it can be done as an alias in cshrc).

"bash-p" 5.12 =
#!/bin/bash # # <edit warning 2.1> # curhead=$PWD if [ -f ${HEADING:-"..."} ] ; then head=`/bin/cat $HEADING` fi if [ "X$curhead" != "X$head" ] ; then if [ X$TERM = Xxterm ] ; then PWDB=`/usr/bin/basename $PWD` if [ X$USER != Xajh ] ; then TITLE="${USER}@${HOST}:${PWD}" ICON="${USER}@${HOST}:${PWD}" else TITLE="*${PWDB}*${HOST}:${PWD}" ICON="*${PWDB}*${HOST}:${PWD}" fi echo -n "<set heading 5.13>" fi head=$curhead if [ -f ${HEADING:-"..."} ] ; then echo $head >$HEADING fi fi

The following wonderful piece of code is the magic to set the X windows title bar to the host name and directory, in the format HOST:directory for the full window, and HOST:basename for the iconified form.

However, since we cannot enter the character sequence directly, the code must be translated subsequently to include the escape characters. This is done in the Makefile, by translating the temporary file bash-p to bash-prompt.

<set heading 5.13> = {esc}]2;${TITLE}{bel}{esc}]1;${ICON}{bel}
Chunk referenced in 5.12

6. .texrc The TeX Resource Control file

This file is responsible for setting environment variables to enable {\TeX} to run. I've made it a separate file, so that it can be sourced from other places as necessary to use {\TeX}.

".texrc" 6.1 =
#<edit warning 2.1> case $HOST in ararat | ballarat | bendigo | bittern | clematis | \ dimboola | rainbow | meconopsis | murtoa | \ dyn* | roaming-* | its--roaming | dhcp7-218* | bsit-roaming* ) \ <texrc for MacOSX 6.2>;;{Note 6.1.1} hawthorn)<texrc for hawthorn 6.3>;; eregnans* | regnans* )<texrc for non-tex machines 6.4>;; cerg* | vm-cerg* )<texrc for non-tex machines 6.4>;; *) echo "No case branch for .texrc for $HOST" ;; esac
{Note 6.1.1}
note: NO LEADING SPACES!
<texrc for MacOSX 6.2> =
TEXINPUTS=".:\ $HOME/Computers/tex/inputs:\ $HOME/Computers/tex/tex-in-practice:\ $HOME/lib/texmf/tex:\ $HOME/lib/texmf/tex/plain:\ $HOME/lib/texmf/tex/latex:\ $HOME/lib/texmf/tex/latex/beamer/base:\ /usr/local/share/texmf:\ /sw/share/texmf:" export TEXINPUTS TEXFORMATS="/sw/var/lib/texmf/web2c:" export TEXFORMATS
Chunk referenced in 6.1

20050725:160750 Removed the TEXFORMATS path to my local formats directory. This is now handled in the ~/lib/texmf directory.

<texrc for hawthorn 6.3> =
TEXINPUTS=".:\ /usr/share/texmf-tetex/tex/generic/babel:\ /usr/share/texmf-tetex/tex/latex/amsfonts:\ /usr/share/texmf-tetex/tex/latex/base:\ /usr/share/texmf-tetex/tex/latex/graphics:\ /usr/share/texmf-tetex/tex/latex/hyperref:\ /usr/share/texmf-tetex/tex/latex/misc:\ /usr/share/texmf-tetex/tex/latex/tools:\ $HOME/Computers/tex/tex-in-practice:\ $HOME/Computers/tex/inputs:" export TEXINPUTS TEXFORMATS="$HOME/tex/formats:/usr/share/texmf/web2c:" export TEXFORMATS
Chunk referenced in 6.1
<texrc for non-tex machines 6.4> =
Chunk referenced in 6.1

Empty, because we don't use TeX on these machines

7. .sgmlrc The SGML Resource Control file

This file is responsible for setting environment variables to enable SGML and related programs to run. I've made it a separate file, so that it can be sourced from other places as necessary to use SGML.

".sgmlrc" 7.1 =

8. Logging out: .bash_logout

".bash_logout" 8.1 =
if [ ${HEADING:-0} != 0 ] ; then rm $HEADING fi if [ $LOGINLVL -eq 0 ] ; then rm $HOME/etc/heading* rm $HOME/.online fi

Remove the window heading file for this process, and clean up all the window heading and counting files if we are at the bash shell level.

Kill any rootimage (background image) process.

9. Window Colours

This section is defined here not so much because it is used by this suite, as because it seems the best place to define what are system wide resources, used in a range of applications. Cut and paste the following definitions as required.

R=FF
B=FF B=CC B=99 B=66
G=FF ffffff <bg-colour-murtoa 9.1> = rgb:ff/ff/cc
Chunk referenced in 3.48
(Note: murtoa, ararat and quorn swapped 20090305:104557)
<bg-colour-ararat 9.2> = rgb:ff/ff/99
Chunk referenced in 3.48 9.21
(Note: murtoa, ararat and quorn swapped 20090305:104557)
<bg-colour-quorn 9.3> = rgb:ff/ff/66
(Note: murtoa, ararat and quorn swapped 20090305:104557)
G=CC <bg-colour-nexus 9.4> = rgb:ff/cc/ff
Chunk referenced in 9.21
<bg-colour-bendigo 9.5> = rgb:ff/cc/cc
Chunk referenced in 3.48
<bg-colour-sequoia 9.6> = rgb:ff/cc/99
<bg-colour-eregnans 9.7> = rgb:ff/cc/66
Chunk referenced in 3.48
G=99 ff99ff ff99cc ff9999
R=DD
B=FF B=DD B=CC B=99 B=66
G=FF <bg-colour-bittern 9.8> = rgb:dd/ff/ff
Chunk referenced in 3.48
<bg-colour-dimboola 9.9> = rgb:dd/ff/dd
Chunk referenced in 3.48
(Note: ballarat moved to rgb:cc/ff/cc 20091130:121618; modified to rgb:dd/ff/dd 20100107:115045)
G=DD
G=CC
G=99
R=CC
B=FF B=CC B=99 B=66
G=FF <bg-colour-cerg 9.10> = rgb:cc/ff/ff
Chunk referenced in 9.21
(Note: cerg and hawthorn colours swapped 20090303:104915)
dimboola modified to rgb:dd/ff/dd 20100107:115045) <bg-colour-rainbow 9.11> = rgb:cc/ff/99
Chunk referenced in 3.48 9.21
<bg-colour-ballarat 9.12> = rgb:cc/ff/66
Chunk referenced in 3.48 9.21
(Note: moved to make room for dimboola 20091130:121618)
G=CC <bg-colour-sng 9.13> = rgb:cc/cc/ff
Chunk referenced in 9.21
cccccc <bg-colour-garedelyon 9.14> = rgb:cc/cc/99
G=99 <bg-colour-hawthorn 9.15> = rgb:cc/99/ff
Chunk referenced in 9.21
(Note: cerg and hawthorn colours swapped 20090303:104915)
cc99cc <bg-colour-bruce 9.16> = rgb:cc/99/99/
Chunk referenced in 9.21
R=99
B=FF B=CC B=99
G=FF <bg-colour-clematis 9.17> = rgb:99/ff/ff
Chunk referenced in 3.48
<bg-colour-central 9.18> = rgb:99/ff/cc
Chunk referenced in 9.21
<bg-colour-meconopsis 9.19> = rgb:99/ff/99
G=CC 99ccff 99cccc 99cc99
G=99 9999ff 9999cc 999999
R=66
B=FF B=CC B=99
G=FF <bg-colour-redfern 9.20> = rgb:66/ff/99
Chunk referenced in 9.21

For reference:

Hex Decimal
ff 255
cc 204
99 153
66 102
33 51
0 0
<colours 9.21> =
<bg-colour-ararat 9.2> <bg-colour-ballarat 9.12> <bg-colour-rainbow 9.11> <bg-colour-central 9.18> <bg-colour-redfern 9.20> <bg-colour-hawthorn 9.15> <bg-colour-sng 9.13> <bg-colour-cerg 9.10> <bg-colour-nexus 9.4> <bg-colour-bruce 9.16> <bg-colour-junee >

10. The Makefile

The Makefile handles the nitty-gritty of copying files to the right places, and setting permissions, etc.

Note the nifty use of ${HOST} as parameter to nutweb to get the right version of things for the current platform created. This is used in all the @>$1@] references in macros such as <where is bash on {machine} > and <texrc definition >.

"Makefile" 10.1 =
default=setup flags=-2 bash WEBPAGE=/home/ajh/public_html/research/literate FILES=.bash_profile .bashrc .bash_logout XSLLIB=/home/ajh/lib/xsl XSLFILES=$(XSLLIB)/lit2html.xsl $(XSLLIB)/tables2html.xsl INSTALLFILES=${HOME}/.bash_profile \ ${HOME}/.texrc \ ${HOME}/.bash_logout \ ${HOME}/bin/setmachine \ ${HOME}/bin/bash-prompt \ ${HOME}/.bashrc \ ${HOME}/.set_colours.sh include $(HOME)/etc/MakeXLP setup.tangle setup.xml: setup.xlp colours.xlp xsltproc --xinclude -o setup.xml $(XSLLIB)/litprog.xsl setup.xlp touch setup.tangle setup.html: setup.xml $(XSLFILES) xsltproc --xinclude $(XSLLIB)/lit2html.xsl setup.xml >setup.html install: $(INSTALLFILES) synch: /home/ajh/bin/synch -tfr ${default}.w upload: rsync -auv *.w hawthorn:`pwd` web: $(WEBPAGE)/setup.html $(WEBPAGE)/setup.html: setup.html cp -p setup.html $(WEBPAGE)/setup.html bash-prompt: setup.tangle /home/ajh/bin/trans-esc-bel bash-p bash-prompt ${HOME}/%: % @if [ -f $@ ] ; then \ diff -q $@ $< >/dev/null ;\ if [ $$? -eq 1 ] ; then \ echo cp $< $@ ;\ cp $< $@ ;\ fi ;\ else \ echo cp $< $@ ;\ cp $< $@ ;\ fi ${HOME}/bin/%: % @if [ -f $@ ] ; then \ diff -q $@ $< >/dev/null ;\ if [ $$? -eq 1 ] ; then \ echo chmod 755 $< ; cp $< $@ ;\ chmod 755 $< ;\ cp $< $@ ;\ fi ;\ else \ echo chmod 755 $< ; cp $< $@ ;\ chmod 755 $< ;\ cp $< $@ ;\ fi install-setmachine: setup.tangle chmod 755 setmachine cp setmachine ${HOME}/bin/ touch install-setmachine install-upload: setup.tangle chmod 755 upload cp upload ${HOME}/bin/ touch install-upload install-set-colours: setup.tangle cp .set_colours.sh ${HOME}/ touch install-set-colours install-sync-common: setup.tangle chmod 755 sync-common cp sync-common ${HOME}/bin touch install-sync-common all: install setup.dvi Makefile: setup.tangle

I had to kludge the bash-prompt construction. Since it relies upon two control characters that foul up this literate program, they are represented by the strings {esc} and {bel} respectively in the bash-prompt template file, bash-p (See <set heading 5.13>). A sed script in the Makefile trans-esc-bel then does the magic of converting these to the real thing. The definitions of the shell variables e and b allow us to manipulate the otherwise unrepresentable control characters. Each of these is formed by translating a dummy character into the control character.

This was the entry in the Makefile, but it doesn't appear to work.

20091020:093027 The list of files to install has been re-ordered, so that .bashrc appears last. It is the one causing the error, but it still seems to install correctly. By making it last, all the other (non-error making) ones get installed first.

	e=`echo e | tr e '\033'` \
	b=`echo b | tr b '\007'` \
	sed -e "s/{esc}/$$e/g" -e "s/{bel}/$$b/g" bash-p >bash-prompt
  

11. Indices

11.1 Files

File Name Defined in
.bash_logout 8.1
.bash_profile 3.1
.bashrc 5.1
.set_colours.sh 3.48
.sgmlrc 7.1
.texrc 6.1
Makefile 10.1
bash-p 5.12
setmachine 4.1

11.2 Chunks

Chunk Name Defined in Used in
bash: set variables 3.8 3.1
bashrc: set the prompt 5.10 5.1
bashrc: setup aliases 5.2, 5.3 5.1
bg-colour-ararat 9.2 3.48, 9.21
bg-colour-ballarat 9.12 3.48, 9.21
bg-colour-bendigo 9.5 3.48
bg-colour-bittern 9.8 3.48
bg-colour-bruce 9.16 9.21
bg-colour-central 9.18 9.21
bg-colour-cerg 9.10 9.21
bg-colour-clematis 9.17 3.48
bg-colour-dimboola 9.9 3.48
bg-colour-eregnans 9.7 3.48
bg-colour-garedelyon 9.14
bg-colour-hawthorn 9.15 9.21
bg-colour-meconopsis 9.19
bg-colour-murtoa 9.1 3.48
bg-colour-nexus 9.4 9.21
bg-colour-quorn 9.3
bg-colour-rainbow 9.11 3.48, 9.21
bg-colour-redfern 9.20 9.21
bg-colour-sequoia 9.6
bg-colour-sng 9.13 9.21
colours 9.21
current date .2 3.1, 5.1
current version .1 3.1, 5.1
determine if primary login 5.11 5.1
determine where we are 3.3, 3.4, 3.5 3.1, 5.1
determine where we are - expr 3.6
determine who we are 3.2 3.1
do non-root related login things here 3.32 3.8
do root related login things here 3.31 3.8
record where we are 3.7 3.1
set LD LIBRARY PATH environment variable 3.45 3.33
set MANPATH environment variable 3.46 3.33
set SERVER environment variable 3.44 3.33
set XMLLIB environment variable 3.47 3.33
set common path for Linux systems 3.28 3.14, 3.15, 3.18, 3.19, 3.25
set common path for MacOSX systems 3.27 3.10, 3.11, 3.12, 3.13, 3.16, 3.17, 3.20, 3.21, 3.23, 3.29
set env vars for CVS on MacOSX systems 3.43 3.39
set env vars for CVS on hawthorn 3.42 3.35
set env vars for MacOSX 3.39 3.33, 3.33, 3.33, 3.33, 3.33
set env vars for central 3.36 3.33
set env vars for cerg 3.37 3.33
set env vars for eregnans 3.38 3.33, 3.33
set env vars for hawthorn 3.35 3.33
set env vars for sng 3.40 3.33
set environment for ciao prolog 3.34 3.33
set heading 5.13 5.12
set path for ararat 3.10 3.9
set path for ballarat 3.11 3.9
set path for bendigo 3.12 3.9
set path for bittern 3.13 3.9
set path for central 3.14 3.9
set path for cerg 3.15 3.9
set path for clematis 3.16 3.9
set path for defaults 3.29 3.9
set path for dimboola 3.17 3.9
set path for eregnans 3.25 3.9
set path for garedelyon 3.18 3.9
set path for hawthorn 3.19 3.9
set path for meconopsis 3.20 3.9
set path for murtoa 3.21 3.9
set path for nexus 3.22 3.9, 3.9, 3.9
set path for quorn 3.23 3.9
set path for rainbow 3.24 3.9
set path for sng 3.26 3.9
set paths on all machines 3.9, 3.30 3.8
set paths on all machines 3.9, 3.30 3.8
set sundry environment variables 3.33 3.8
set the perl library for MacOSX systems 3.41 3.39
specific aliases for eregnans 5.5 5.3
specific aliases for hawthorn 5.4 5.3
specific aliases for macosx leopard 5.8 5.3
specific aliases for macosx snow leopard 5.9 5.3
specific aliases for macosx tiger 5.7 5.3
specific aliases for nexus 5.6 5.3
texrc for MacOSX 6.2 6.1
texrc for hawthorn 6.3 6.1
texrc for non-tex machines 6.4 6.1, 6.1

11.3 Identifiers

Identifier Defined in Used in

Document History

mdfer6@student.monash.edu mdfer6@student.monash.edu
15 Dec 1998 John Hurst 1.0 first version to get a version number!
13 Jan 1999 John Hurst 1.0.1 add RSYNC_RSH enviro. .bash_profilenment variable
21 Mar 1999 John Hurst 1.0.2 revise LOGINLVL stuff
02 Jun 1999 John Hurst 1.1 add environment variable SERVER to indicate which X server we have
07 Jun 1999 John Hurst 1.1.1 create file .bash_profile, rather than .profile
16 Jun 1999 John Hurst 1.1.2 add /usr/etc to PATH on indy03
22 Jun 1999 John Hurst 1.2 change to Gnome
23 Jun 1999 John Hurst 1.2.1 for just hawthorn
24 Jun 1999 John Hurst 1.2.2 hawthorn fine tunings
15 Jul 1999 John Hurst 1.3 add .xsession make generator for indy03
03 Aug 1999 John Hurst 1.3.1 add Star Office link on hawthorn
16 Aug 1999 John Hurst 1.3.2 change RSYNC_RSH back to ssh
23 Aug 1999 John Hurst 1.3.3 revise LOGINLVL stuff (again)!
24 Aug 1999 John Hurst 1.3.4 add jade to PATH
20 Sep 1999 John Hurst 1.3.5 add jadetex to TEXINPUTS, ASSOCDB
23 Sep 1999 John Hurst 1.3.6 start an xterm in .xinitrc
27 Sep 1999 John Hurst 1.3.7 updates for changed indy03
12 Dec 1999 John Hurst 1.3.8 PATH and libraries for XML4C2
14 Dec 1999 John Hurst 1.3.9 add XMLLIB environment variable
13 Feb 2000 John Hurst 1.4.0 switch to xlp processing, and remove indy03 references
24 Jun 2000 John Hurst 1.4.1 revise use of horizontal rules
17 Aug 2000 John Hurst 1.4.2 add new central (called junee)
19 Aug 2000 John Hurst 1.4.3 substantial revisions to bring into line with junee
07 Sep 2000 John Hurst 1.4.4 revision icon title of xterm
24 May 2001 John Hurst 1.4.5 (forgot to fill this in!)
21 Jun 2001 John Hurst 1.4.6 remove startup msgs for .bash_profile, .bashrc
06 May 2002 John Hurst 1.4.7 revise \$PATH
09 May 2002 John Hurst 1.4.8 add upload and sync-common, revise \$LOGINLVL setup
21 Jan 2003 John Hurst 1.4.9 add machine colours
20030316:111816 John Hurst 1.4.10 extend and revise machine colours
20040124:164708 John Hurst 1.4.11 remove junee and add meconopsis
20040313:174404 ajh 1.4.12 add colons at end of .texrc initialisations
20040609:094845 ajh 1.4.13 remove window numbering stuff as obsolete
20040904:121839 ajh 1.4.14 add rainbow to list of hosts
20050408:104809 ajh 1.4.15 Add BALLARAT environment variable
20050409:140618 ajh 1.4.16 Add ARARAT environment variable
20050504:102025 ajh 1.4.17 move BALLARAT ARARAT settings to separate file
20050725:131418 ajh 1.4.18 add setup for dhcp7-218 (Swinburne). Fixed .texrc error with new texmf structure.
20060410:094906 ajh 1.4.19 added new laptop murtoa (MacBook Pro)
20061209:115828 ajh 1.5.0 add ajh.id.au/njhurst.com/sequoia machine
20070417:154051 ajh 1.5.1 add clematis machine
20070417:163223 ajh1.5.2 cleaned up some obsolete code (.xinitrc, etc.)
20080305:084924ajh 1.5.3 added bsit-roaming site
20080312:092253 ajh 1.5.4 revised dyn- hostnames to not include any IP component
20090305:101021 ajh 1.5.5 revised new colour scheme for murtoa
20090306:095359 ajh 1.6.0 split out colour setting as separate file
20090409:144431 ajh 1.6.1 added 'roaming-*' to hostnames
20100226:094026 ajh 1.7.0 added eregnans to list of machines
20100603:163502 ajh 1.8.0 added new laptop bittern (MacBook Pro)
20101213:170646 ajh 1.8.1 redo hostname to use -s flag
20110930:143945 ajh 1.8.2 minor updates for eregnans
<current version .1> = 1.8.1
Chunk referenced in 3.1 5.1
<current date .2> = 20101213:170646
Chunk referenced in 3.1 5.1