瀏覽代碼

Be smarter about terminal title icon

First, I'm not sure where I took the former icon, but it does not work
out of the bos on Fedora, so I decided to use another one rather than
try to find out.

Also when a system is accessed via SSH, it will use different
(fa-server) icon.
Alois Mahdal 7 年之前
父節點
當前提交
d9db4da860
共有 1 個檔案被更改,包括 10 行新增3 行删除
  1. 10
    3
      dotfiles/bash/post.bashrc

+ 10
- 3
dotfiles/bash/post.bashrc 查看文件

82
             # output them.
82
             # output them.
83
             ;;
83
             ;;
84
         "")
84
         "")
85
-            echo -ne "\033]0; "
85
+            echo -ne "\033]0;$(__bashum__mkicon) "
86
             echo -n    "$(__bashum__lastrv)$(__bashum__mkhostid)${PWD/$HOME/\~}\$"
86
             echo -n    "$(__bashum__lastrv)$(__bashum__mkhostid)${PWD/$HOME/\~}\$"
87
             echo -ne "\007"
87
             echo -ne "\007"
88
             ;;
88
             ;;
89
         *)
89
         *)
90
-            echo -ne "\033]0; "
90
+            echo -ne "\033]0;$(__bashum__mkicon) "
91
             echo -n    "${BASH_COMMAND} ($(__bashum__mkhostid)${PWD/$HOME/\~})"
91
             echo -n    "${BASH_COMMAND} ($(__bashum__mkhostid)${PWD/$HOME/\~})"
92
             echo -ne "\007"
92
             echo -ne "\007"
93
             ;;
93
             ;;
103
     case "$TERM" in
103
     case "$TERM" in
104
         xterm*|rxvt*|screen*)
104
         xterm*|rxvt*|screen*)
105
             echo -n 'echo -ne "\033]0;'
105
             echo -n 'echo -ne "\033]0;'
106
-            echo -n   ' '
106
+            echo -n   "$(__bashum__mkicon) "
107
             echo -n   '$(__bashum__lastrv)'
107
             echo -n   '$(__bashum__lastrv)'
108
             echo -n   "$(__bashum__mkhostid)"
108
             echo -n   "$(__bashum__mkhostid)"
109
             echo -n   '${PWD/$HOME/\~}'
109
             echo -n   '${PWD/$HOME/\~}'
113
     esac
113
     esac
114
 }
114
 }
115
 
115
 
116
+__bashum__mkicon() {
117
+    case "$SSH_CONNECTION" in
118
+        "") echo  ;;
119
+        *)  echo  ;;
120
+    esac
121
+}
122
+
116
 __bashum__mkhostid() {
123
 __bashum__mkhostid() {
117
     test -n "$SSH_CONNECTION" || return
124
     test -n "$SSH_CONNECTION" || return
118
     echo "${HOSTNAME%%.*}:"
125
     echo "${HOSTNAME%%.*}:"