chiark / gitweb /
Merge remote-tracking branch 'crybaby'
authorMark Wooding <mdw@distorted.org.uk>
Sun, 15 May 2011 11:35:09 +0000 (12:35 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 15 May 2011 11:35:09 +0000 (12:35 +0100)
* crybaby:
  dot/bash*: Reformat.
  mc: Store configuration and arrange for linkage.

1  2 
dot/bash_profile
setup

diff --combined dot/bash_profile
index 7d3bf4c231eced0bdec5c4cd72e0d304a3fd21d0,de5a5cf551ac96411ca5f014f40bee9290fa8d34..1621d13d56cb4182015d063bba1d934fbf520afd
@@@ -1,23 -1,25 +1,25 @@@
- # -*-sh-*-
- #
- # Bash startup things
- #
+ ### -*-sh-*-
+ ###
+ ### Bash startup things
  
+ ## Only do any of this if we haven't done it before.  Otherwise we
+ ## can have loops and lots of wasted time.
  if [ -z "$__mdw_profile" ]; then
  export __mdw_profile=done
  
- # --- Work out my home directory ---
- #
- # This horrible trick resolves symbolic links.  It enables resolving links,
- # changes directory and displays the name of the directory in a subshell
- # to avoid changing the current state.
- HOME=`(set -P; cd $HOME; pwd)`
- cd $HOME
- # --- Add elements to a path string ---
+ ###--------------------------------------------------------------------------
+ ### Utility functions.
+ ## __mdw_addto VAR DIR PATH ...
+ ##
+ ## VAR is the name of a PATH-like environment variable (i.e., one which
+ ## contains a sequence of pathnames separated by colons).  DIR is either `l'
+ ## or `r'.  The PATHs are pathnames.  Those PATHs which correspond to
+ ## existing directories but which aren't currently named in the variable are
+ ## added to the left or right (depending on DIR) of VAR.  The relative order
+ ## of PATHs added in the same invokation is the same as the order they
+ ## appeared in PATHs: the DIR argument only affects which end of the VAR they
+ ## get added to.
  __mdw_addto () {
    local var=$1 val dir=$2 new="" change=nil
    eval "val=\$$var"
      case "$new:" in *:$i:*) continue;; esac
      [ -d $i ] || continue
      case "X$val" in
-       X)
-       val=$i change=t
-       continue
-       ;;
-       X$i)
-       continue
-       ;;
-       X*:$i:*)
-       val=`echo $val | sed -e "s=:$i:=:="`
-       ;;
-       X$i:*)
-       val=${val#$i:}
-       ;;
-       X*:$i)
-       val=${val%:$i}
-       ;;
+       X) val=$i change=t continue ;;
+       X$i) continue ;;
+       X*:$i:*) val=`echo $val | sed -e "s=:$i:=:="` ;;
+       X$i:*) val=${val#$i:} ;;
+       X*:$i) val=${val%:$i} ;;
      esac
      new=$new:$i change=t
    done
    case $dir in
-     l) val=${new#:}:$val;;
-     r) val=$val$new;;
+     l) val=${new#:}:$val ;;
+     r) val=$val$new ;;
    esac
    case $change in t) export $var="$val" ;; esac
  }
  
- # --- Set the path variable ---
+ ## __mdw_programp NAME
+ ##
+ ## Does NAME exist as an executable program?
+ __mdw_programp () { type -t >/dev/null "$1"; }
+ ###--------------------------------------------------------------------------
+ ### Other preliminaries.
+ ## Work out my home directory.
+ ##
+ ## This horrible trick resolves symbolic links.  It enables resolving links,
+ ## changes directory and displays the name of the directory in a subshell to
+ ## avoid changing the current state.
+ HOME=`(set -P; cd $HOME; pwd)`
+ cd $HOME
+ ## Establish a temporary directory.
+ [ "$TMPDIR" ] || eval `tmpdir -b`
+ export TMP=$TMPDIR
+ ## CDE's session structure is demented and doesn't leave us with a proper
+ ## logout hook, so synthesize one here.
+ [ -n "$DT" ] && trap "source $HOME/.bash_logout" EXIT
+ ###--------------------------------------------------------------------------
+ ### Set some basic paths.
  
+ ## The main path.
  __mdw_addto PATH l \
    $HOME/bin \
    {,/usr{,/local}{,/X11R6}}{/bin,/sbin,/games} \
    /opt/nfast{,/gcc}{/bin,/sbin} \
    $HOME/src/ncipher/scripts
+ ## If we have Plan 9 from User Space, then add that in.
  if [ -d /usr/local/plan9 ]; then
    export PLAN9=/usr/local/plan9
    __mdw_addto PATH r \
      $PLAN9/bin
  fi
  
- # --- Find whether a program exists ---
- __mdw_programp () { type -t >/dev/null "$1"; }
+ ## Search for `info' documents.
+ __mdw_addto INFOPATH r \
+       $HOME/info \
+       /usr/info /usr/share/info \
+       /usr/local/info /usr/local/share/info \
+       /usr/local/share/info/its
  
- # --- And the same for manual pages ---
+ ## Script libraries.
+ __mdw_addto PERLLIB r $HOME/lib/perl
+ __mdw_addto PYTHONPATH r $HOME/lib/python
  
- case "$MACHTIME" in
-   *linux*)
-     MANPATH=`manpath -q`
-     ;;
- esac
- __mdw_addto MANPATH l \
-   {/usr{,/local}{,/X11R6}{,/share}}/{man,catman} \
-   $HOME/man
+ ###--------------------------------------------------------------------------
+ ### Various other kinds of configuration.
  
- # --- Where my mail comes from ---
+ ## Sensible umask if users have their own groups.
+ umask 002
  
+ ## Mail and general identification.
  export MAIL=`mdw-conf mailbox`
  export NAME="Mark Wooding"
  export EMAIL=`mdw-conf email`
  export QMAILINJECT=c
  
- # --- Find a text editor ---
+ ## Some programs want to know the hostname.
+ [ -z "$HOST" ] && export HOST=`hostname`
  
+ ## Text editor configuration.
  export MDW_EDITOR=ed
  emacs_startup_args="--no-site-file --mdw-fast-startup -nw"
  for ed in \
      break
    fi
  done
  export EDITOR=mdw-editor VISUAL=mdw-editor
  
- # --- Various options for programs ---
- umask 002
- [ -z "$HOST" ] && export HOST=`hostname`
+ ## Determine the locale settings.  Really don't set LC_COLLATE because it
+ ## messes with the order of files in `ls' listings and similar.
  if [ "$DISPLAY" != "" ]; then
    LANG=`mdw-conf x-ctype`
  else
    : ${LANG=${LC_CTYPE-${LC_ALL-`mdw-conf console-ctype`}}}
    case "$TERM,`tty`" in
      linux,/dev/tty*)
 -      if vt-is-UTF8 >/dev/null 2>&1; then
 +      if { vt-is-UTF8 ||
 +         kbd_mode | grep UTF-8; } >/dev/null 2>&1; then
        ctype=.utf8
        else
        ctype=
@@@ -131,31 -147,7 +148,7 @@@ f
  unset LC_ALL
  export LC_COLLATE=POSIX LANG
  
- __mdw_programp distcc && export CCACHE_PREFIX=distcc
- export TEXINPUTS=".:$HOME/lib/tex//:"
- __mdw_addto INFOPATH r \
-       $HOME/info \
-       /usr/info /usr/share/info \
-       /usr/local/info /usr/local/share/info \
-       /usr/local/share/info/its
- __mdw_addto PERLLIB r $HOME/lib/perl
- __mdw_addto PYTHONPATH r $HOME/lib/python
- export __MDW_ROOTLY=`mdw-conf rootly`
- [ -z "$LS_OPTIONS" ] && export LS_OPTIONS="-F"
- export BASCAT="-l +n"
- export CVS_RSH=ssh
- export CVSROOT=`mdw-conf cvs-root`
- export SVNROOT=`mdw-conf svn-root`
- export P4CONFIG=.p4
- export BECOME="--preserve-environment"
+ ## Pager configuration.
  export MDW_PAGER=`type -p less` PAGER=mdw-pager METAMAIL_PAGER=mdw-pager
  export LESS="-iqgRh1FX"
  export LESSOPEN="|lesspipe.sh %s"
@@@ -165,14 -157,8 +158,8 @@@ case "${LC_CTYPE-$LANG}" i
  esac
  export LESSCHARSET
  __mdw_programp global && export LESSGLOBALTAGS=global
- export NCURSES_NO_UTF8_ACS=1
- # export MAKEFLAGS="-j4"
- [ "$TMPDIR" ] || eval `tmpdir -b`
- export TMP=$TMPDIR
- export PERL_READLINE_NOWARN=yes
- [ -z "$NNTPSERVER" ] && export NNTPSERVER=`mdw-conf nntp-server`
  
+ ## HTTP and FTP proxies.
  http=`mdw-conf http-proxy none`
  case "${http_proxy-none},$http" in
    *,none) ;;
@@@ -185,20 -171,55 +172,55 @@@ case "${ftp_proxy-none},$ftp,${http_pro
    none,*,*) export ftp_proxy=http://$ftp/ ;;
  esac
  
+ ## Ncurses programs should use the Unicode box-drawing characters because the
+ ## alternative character set stuff isn't supported well.
+ export NCURSES_NO_UTF8_ACS=1
+ ## Shut up Perl's readline machinery.
+ export PERL_READLINE_NOWARN=yes
+ ## If we have `distcc' then tell `ccache' to use it.
+ __mdw_programp distcc && export CCACHE_PREFIX=distcc
+ ## Acquiring root privileges.  This is mainly the job of `bashrc', but we
+ ## cache the mechanism here.
+ export __MDW_ROOTLY=`mdw-conf rootly`
+ export BECOME="--preserve-environment"
+ ## It's useful to see the little sigils in `ls'.
+ [ -z "$LS_OPTIONS" ] && export LS_OPTIONS="-F"
+ ## Settings for BBC BASIC listing.
+ export BASCAT="-l +n"
+ ## Version control hacking.
+ export CVS_RSH=ssh
+ export CVSROOT=`mdw-conf cvs-root`
+ export SVNROOT=`mdw-conf svn-root`
+ export P4CONFIG=.p4
+ ## News server.
+ [ -z "$NNTPSERVER" ] && export NNTPSERVER=`mdw-conf nntp-server`
+ ## Help X programs find their resources.
  export XUSERFILESEARCHPATH="$HOME/.Xapps/%N:/usr/lib/X11/%T/%N%S"
  
+ ## Make OpenOffice.org do its thing properly.
  export OOO_FORCE_DESKTOP=gnome
  
+ ## Configure `ps'.
  export PS_PERSONALITY=gnu
  
- export NC_SITES=cam:bos
- # -- Disable core dumps ---
+ ## Disable core dumps.
  ulimit -S -c 0
  
- # --- Start an ssh authentication agent ---
+ ###--------------------------------------------------------------------------
+ ### Authentication and SSH hacking.
  
+ ## Start an authentication agent.  This is unnecessarily fiddly.  If there's
+ ## a Gnome keyring server then we should use that; unfortunately, it may not
+ ## yet have had a chance to populate the environment with its settings, so we
+ ## go off and fetch them.
  if { { [ "$GNOME_KEYRING_CONTROL" ] &&
         [ -s "$GNOME_KEYRING_CONTROL" ]; } ||
       { [ "$DBUS_SESSION_BUS_ADDRESS" ] &&
@@@ -211,8 -232,12 +233,12 @@@ the
    export SSH_AUTH_SOCK
  fi
  
+ ## If we still don't have an agent then start one with a stable name.
  eval `start-ssh-agent -b`
  
+ ## Decide whether this session should be considered `secure'.  A session is
+ ## secure if it's on a secure TTY, but there are lots of ways of finding out
+ ## which TTYs are secure.
  if [ -z "$__mdw_bashrc" ] && [ "$__mdw_force_secure_session" = "yes" ] ||
     ( tty="`tty`" devtty="(/dev/)?${tty#/dev/}"
       { { { [ -e /etc/securetty ] && sectty=/etc/securetty; } ||
@@@ -228,10 -253,7 +254,7 @@@ the
    export __mdw_sechost="`hostname`"
  fi
  
- [ -n "$DT" ] && trap "source $HOME/.bash_logout" EXIT
- # --- And a passphrase pixie ---
+ ## Start a passphrase pixie if there is one and it's not already running.
  if pixie --version >/dev/null 2>&1; then
    mkdir -p $HOME/.catacomb
    pixie=${CATACOMB_PIXIE-$HOME/.catacomb/pixie}
    fi
  fi
  
+ ###--------------------------------------------------------------------------
+ ### Finishing touches.
+ ## If there's a local hook then run it.
  [ -f "$HOME/.profile-local" ] && . "$HOME/.profile-local"
  
+ ## End of the `__mdw_profile' guard.
  fi
  
- # --- Now, if my .bashrc hasn't been run yet, run it ---
- #
- # Oh, don't do that if we don't have a terminal.
+ ## If we haven't run the `.bashrc' yet, and this shell is interactive, then
+ ## run it now.
  [ -z "$__mdw_bashrc" ] && [ -t 0 ] && \
    [ -r $HOME/.bashrc ] && . $HOME/.bashrc
+ ###----- That's all, folks --------------------------------------------------
diff --combined setup
index 97be9714ca815cd8da571eb4fbdcfbd9c4d5244f,d1322f506d692050f1bdc4061a476f7924cf4573..79f452df967bae9e5cef0c347d2d6933a08f73d4
--- 1/setup
--- 2/setup
+++ b/setup
@@@ -138,6 -138,7 +138,7 @@@ dotfiles=
    guile
    rcrc
    toprc
+   mc-ini:.mc/ini mc-panels.ini:.mc/panels.ini
    aspell.conf
    lisp-init.lisp:.cmucl-init.lisp
      lisp-init.lisp:.sbclrc
@@@ -229,7 -230,6 +230,7 @@@ scripts=
    mdw-build
    emacsclient-hack
    movemail-hack
 +  sendmail-hack
    aspell-hack
    emerge-hack
    lesspipe.sh