X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=.profile.d%2Fprompt.bashrc;h=44773fc9b4411900c8f141a725eece13a96fac29;hb=2be8b73f0cbc7eef32fb1cbecbb215890858ccb1;hp=a80c6152cf61c3a8d6cb101db5c09fadcf04c0d6;hpb=ef195791b38325931b2d3007b9c409389aa43797;p=profile.git diff --git a/.profile.d/prompt.bashrc b/.profile.d/prompt.bashrc index a80c615..44773fc 100644 --- a/.profile.d/prompt.bashrc +++ b/.profile.d/prompt.bashrc @@ -1,13 +1,18 @@ -# 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. @@ -26,9 +31,9 @@ if ps -o comm= -p $PPID 2>/dev/null | grep '^vim*$' &>/dev/null; then info="$info$vimchild" fi if [ "${TERM##screen}" = "$TERM" ]; then - export PROMPT_COMMAND="echo -ne '\033]0;$info\033\0134\r\033[K'" + PROMPT_COMMAND="echo -ne '\033]0;$info\033\0134\r\033[K'" else - export PROMPT_COMMAND='echo -ne "\033k\033\0134"' + PROMPT_COMMAND='echo -ne "\033k\033\0134"' fi unset blank info vimchild SSH_FORWARDED