Kaynağa Gözat

Do iclude host identification on remote session

Alois Mahdal 10 yıl önce
ebeveyn
işleme
2d8bcec24e
1 değiştirilmiş dosya ile 5 ekleme ve 3 silme
  1. 5
    3
      dotfiles/bash/post.bashrc

+ 5
- 3
dotfiles/bash/post.bashrc Dosyayı Görüntüle

@@ -55,7 +55,9 @@ export PS2=$(make_ps2)
55 55
 
56 56
 case "$TERM" in
57 57
 xterm*|rxvt*|screen*)
58
-    PROMPT_COMMAND='__save_rv $?; echo -ne "\033]0;$(__make_ps1d)${PWD/$HOME/\~}\$\007"'
58
+    test -n "$SSH_CONNECTION" \
59
+     && __host_id="${HOSTNAME%%.*}:"      # i.e. a remote session
60
+    PROMPT_COMMAND='__save_rv $?; echo -ne "\033]0;$(__make_ps1d)$__host_id${PWD/$HOME/\~}\$\007"'
59 61
 
60 62
     # Show the currently running command in the terminal title:
61 63
     # http://www.davidpashley.com/articles/xterm-titles-with-bash.html
@@ -71,9 +73,9 @@ xterm*|rxvt*|screen*)
71 73
             *)
72 74
                 if test -n "${BASH_COMMAND}";
73 75
                 then
74
-                    echo -ne "\033]0;${BASH_COMMAND} (${PWD/$HOME/\~})\007"
76
+                    echo -ne "\033]0;${BASH_COMMAND} ($__host_id${PWD/$HOME/\~})\007"
75 77
                 else
76
-                    echo -ne "\033]0;$(__make_ps1d)${PWD/$HOME/\~}\$\007"
78
+                    echo -ne "\033]0;$(__make_ps1d)$__host_id${PWD/$HOME/\~}\$\007"
77 79
                 fi
78 80
                 ;;
79 81
         esac