Generic handling of SSH_FORWARDED overrides.
[profile.git] / .profile.d / prompt.bashrc
index ad5b1e3..6398e3d 100644 (file)
@@ -1,15 +1,18 @@
-# $Id$
-#
-# Set the title of an xterm to the hostname.
-#
-
-SSH_FORWARDED=$(get_remote_ip -n)
+# Set the title of an xterm to the hostname unless the remote IP is matched by 
+# a regular expression in ~/.ssh/forwarded.
+SSH_FORWARDED=$(get_remote_ip)
 if [ ! -z "$SSH_FORWARDED" ]; then
-  if [ ! "$SSH_FORWARDED" = "62.189.242.202" -a ! "$SSH_FORWARDED" = "62.189.241.202" -a ! "$SSH_FORWARDED" = "193.128.72.68" -a ! "$SSH_FORWARDED" = "localhost" ]; then
-    SSH_FORWARDED=" (from $SSH_FORWARDED)"
-  else
+  if [ "$SSH_FORWARDED" = "localhost" ]; then
     SSH_FORWARDED=
+  elif [ -f ~/.ssh/forwarded ]; then
+    for forwarded in $(< ~/.ssh/forwarded); do
+      if echo "$SSH_FORWARDED" | grep "$forwarded" &>/dev/null; then
+        SSH_FORWARDED=
+      fi
+    done
+    unset forwarded
   fi
+  [ ! -z "$SSH_FORWARDED" ] && SSH_FORWARDED=" (from $(get_remote_ip -n))"
 fi
 
 # Unscientific check for grid jobs.
@@ -33,3 +36,13 @@ else
   export PROMPT_COMMAND='echo -ne "\033k\033\0134"'
 fi
 unset blank info vimchild SSH_FORWARDED
+
+# Actual dtterm barfs on escape sequences.
+if [ "$TERMINAL_EMULATOR" = "dtterm" ]; then
+  unset PROMPT_COMMAND
+fi
+
+# As does screen on an ancient Solaris host.
+if [ -n "$OLDSOLARIS" -a ! "${TERM##screen}" = "$TERM" ]; then
+  unset PROMPT_COMMAND
+fi