dot/profile: Persuade `rsync' not to do silly things to arguments.
[profile] / dot / profile
index 818ae8a..93c5421 100644 (file)
@@ -27,7 +27,6 @@ __mdw_addto () {
     case "$new:" in *:$i:*) continue;; esac
     if ! [ -d $i ]; then continue; fi
     case "$val" in
-      "") val=$i change=t; continue ;;
       $i) continue ;;
       *:$i:*) val=${val%%:$i:*}:${val#*:$i:} ;;
       $i:*) val=${val#$i:} ;;
@@ -36,8 +35,8 @@ __mdw_addto () {
     new=$new:$i change=t
   done
   case $dir in
-    l) val=${new#:}:$val ;;
-    r) val=$val$new ;;
+    l) val=${new#:}${val:+:$val} ;;
+    r) val=${val:+$val:}${new#:} ;;
   esac
   case $change in t) eval $var=\$val ;; esac
 }
@@ -58,6 +57,17 @@ __mdw_setconf () {
   fi
 }
 
+## __mdw_export_if_defined VAR ...
+##
+## If VARs are defined, then export them.
+__mdw_export_if_defined () {
+  local var t
+  for var in "$@"; do
+    eval t=\${$var+t}
+    case $t in t) export $var ;; esac
+  done
+}
+
 ###--------------------------------------------------------------------------
 ### Other preliminaries.
 
@@ -83,14 +93,28 @@ __mdw_addto PATH l \
   /opt/nfast/bin /opt/nfast/sbin
 
 ## If we have Plan 9 from User Space, then add that in.
-if [ -d /usr/local/plan9 ]; then
-  PLAN9=/usr/local/plan9; export PLAN9
-  __mdw_addto PATH r $PLAN9/bin
-fi
+for i in /opt/plan9 /usr/local/plan9; do
+  if [ -d $i ]; then
+    PLAN9=$i; export PLAN9
+    __mdw_addto PATH r $i/bin
+    break
+  fi
+done
+
+## Check for some standard path hacks.
+for i in ccache; do
+  __mdw_addto PATH l "$HOME"/bin/hacks/$i
+done
 
 ###--------------------------------------------------------------------------
 ### Some other preliminaries.
 
+## Set a per-process memory limit.  It's much less common for a process to
+## need a lot of memory for a legitimate reason than for it to be a memory
+## leak or some other bug that's going to cause swap death for no good
+## reason.
+ulimit -Sv $(mdw-conf memory-limit 4194303)
+
 ## Establish a temporary directory.
 case ${TMPDIR+t} in
   t) ;;
@@ -125,8 +149,11 @@ unset ed emacs_startup_args
 ###--------------------------------------------------------------------------
 ### Locale configuration.
 
-case ${DISPLAY+t} in
-  t)
+case ${LC_MDWSSHLANG+t},${DISPLAY+t} in
+  t,*)
+    LANG=$LC_MDWSSHLANG
+    ;;
+  ,t)
     __mdw_setconf LANG x-ctype POSIX
     ;;
   *)
@@ -134,7 +161,7 @@ case ${DISPLAY+t} in
     case "$TERM,$(tty)" in
       linux,/dev/tty*)
        if { vt-is-UTF8 || kbd_mode | grep UTF-8; } >/dev/null 2>&1; then
-         ctype=.utf8
+         ctype=.UTF-8
        else
          ctype=
        fi
@@ -148,6 +175,10 @@ export LANG
 
 LC_COLLATE=POSIX; export LC_COLLATE
 
+case ${LANG+t} in
+  t) LC_MDWSSHLANG=$LANG; export LC_MDWSSHLANG ;;
+esac
+
 ###--------------------------------------------------------------------------
 ### Pagers.
 
@@ -161,8 +192,6 @@ export MDW_PAGER PAGER METAMAIL_PAGER
 unset pg
 
 ## Configure `less'.
-LESS="-iqgRh1j.3FSX"; export LESS
-LESSOPEN="|lesspipe.sh %s"; export LESSOPEN
 case ${LC_CTYPE-$LANG} in
   *utf8 | *utf-8 | *UTF8 | *UTF-8) LESSCHARSET=utf-8 ;;
   *) LESSCHARSET=latin1 ;;
@@ -173,6 +202,9 @@ if __mdw_programp global; then
   export LESSGLOBALTAGS
 fi
 
+## Get Debian `groff' to produce control sequences rather than overstriking.
+GROFF_SGR=t; export GROFF_SGR
+
 ###--------------------------------------------------------------------------
 ### Miscellaneous things.
 
@@ -193,13 +225,19 @@ case "${http_proxy-none},$http" in
   *,none) ;;
   none,*) http_proxy=http://$http/; export http_proxy ;;
 esac
+https=$(mdw-conf https-proxy none)
+case "${https_proxy-none},$https,${http_proxy-none}" in
+  *,none,none) ;;
+  none,none,*) https_proxy=$http_proxy; export https_proxy ;;
+  none,*,*) https_proxy=http://$https/; export ftp_proxy ;;
+esac
 ftp=$(mdw-conf ftp-proxy none)
 case "${ftp_proxy-none},$ftp,${http_proxy-none}" in
   *,none,none) ;;
   none,none,*) ftp_proxy=$http_proxy; export ftp_proxy ;;
   none,*,*) ftp_proxy=http://$ftp/; export ftp_proxy ;;
 esac
-unset http ftp
+unset http https ftp
 
 ## Ncurses programs should use the Unicode box-drawing characters because the
 ## alternative character set stuff isn't supported well.
@@ -227,6 +265,9 @@ unset b
 __mdw_setconf __MDW_ROOTLY rootly
 BECOME="--preserve-environment"; export BECOME
 
+## `rsync' configuration.
+RSYNC_PROTECT_ARGS=1; export RSYNC_PROTECT_ARGS
+
 ## It's useful to see the little sigils in `ls'.
 case ${LS_OPTIONS+t} in t) ;; *) LS_OPTIONS="-F"; export LS_OPTIONS; esac
 
@@ -247,11 +288,35 @@ export XUSERFILESEARCHPATH
 OOO_FORCE_DESKTOP=gnome; export OOO_FORCE_DESKTOP
 
 ## Hack Qt-ish things to be unstoatly.
-QT_STYLE_OVERRIDE=gtk2; export QT_STYLE_OVERRIDE
+##QT_QPA_PLATFORMTHEME=gtk2; export QT_QPA_PLATFORMTHEME
+QT_AUTO_SCREEN_SCALE_FACTOR=0; export QT_AUTO_SCREEN_SCALE_FACTOR
+
+## Use X11 input method (including compose key sequences) everywhere.
+GTK_IM_MODULE=xim; export GTK_IM_MODULE
+QT_IM_MODULE=xim; export QT_IM_MODULE
+
+## Don't hide scrollbars.
+GTK_OVERLAY_SCROLLING=0; export GTK_OVERLAY_SCROLLING
+
+## Rust Cargo things.
+CARGO_HOME=$HOME/.cache/cargo; export CARGO_HOME
 
 ## Configure `ps'.
 PS_PERSONALITY=gnu; export PS_PERSONALITY
 
+## Configure Debian building.
+DEB_BUILD_OPTIONS="parallel=$(mdw-conf make-parallel 4)"
+export DEB_BUILD_OPTIONS
+
+## Turn off angry fruit salad error messages from things.
+DPKG_COLORS=never; export DPKG_COLORS
+GCC_COLORS=; export GCC_COLORS
+CCC_OVERRIDE_OPTIONS="#^-fno-color-diagnostics"; export CCC_OVERRIDE_OPTIONS
+
+## Local library directories.
+__mdw_addto PERLLIB l $HOME/lib/perl; __mdw_export_if_defined PERLLIB
+__mdw_addto PYTHONPATH l $HOME/lib/python; __mdw_export_if_defined PYTHONPATH
+
 ## Disable core dumps.
 ulimit -S -c 0