Use a different escape sequence for magenta.
[profile.git] / .profile.d / prompt.bashrc
1 # $Id$
2 #
3 # Set the title of an xterm to the hostname.
4 #
5
6 SSH_FORWARDED=$(get_remote_ip -n)
7 if [ ! -z "$SSH_FORWARDED" ]; then
8   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
9     SSH_FORWARDED=" (from $SSH_FORWARDED)"
10   else
11     SSH_FORWARDED=
12   fi
13 fi
14
15 # Unscientific check for grid jobs.
16 case ${SSH_CLIENT##* } in
17   ""|22|2222);;
18   *) SSH_FORWARDED="$SSH_FORWARDED [grid]"
19 esac
20
21 info="$HOSTNAME$SSH_FORWARDED"
22
23 # Check for vim.
24 vimchild=" [vim]"
25 if ps -o comm= -p $PPID 2>/dev/null | grep '^vim*$' &>/dev/null; then
26   # Clear [vim] when exiting.
27   trap "echo -ne '\\033]0;$info\\033\\0134'" exit
28   info="$info$vimchild"
29 fi
30 if [ "${TERM##screen}" = "$TERM" ]; then
31   export PROMPT_COMMAND="echo -ne '\033]0;$info\033\0134\r\033[K'"
32 else
33   export PROMPT_COMMAND='echo -ne "\033k\033\0134"'
34 fi
35 unset blank info vimchild SSH_FORWARDED
36
37 # Actual dtterm barfs on escape sequences.
38 if [ "$TERMINAL_EMULATOR" = "dtterm" ]; then
39   unset PROMPT_COMMAND
40 fi