소스 검색

Add code to show command in titlebar

Taken from an [i3 forum answer][1] and edited to remove unnecessary info
(name@hostname and $HOME path)

  [1]: https://faq.i3wm.org/question/2481/how-to-show-cli-application-name-in-window-title/?answer=2482#post-id-2482
Alois Mahdal 10 년 전
부모
커밋
0f4133012a
1개의 변경된 파일28개의 추가작업 그리고 0개의 파일을 삭제
  1. 28
    0
      dotfiles/bash/post.bashrc

+ 28
- 0
dotfiles/bash/post.bashrc 파일 보기

@@ -52,3 +52,31 @@ export PS2=$(make_ps2)
52 52
 ### OTHERS ###
53 53
 ### '''''' ###
54 54
 
55
+case "$TERM" in
56
+xterm*|rxvt*|screen*)
57
+    PROMPT_COMMAND='echo -ne "\033]0;${PWD/$HOME/~}\$\007"'
58
+
59
+    # Show the currently running command in the terminal title:
60
+    # http://www.davidpashley.com/articles/xterm-titles-with-bash.html
61
+    show_command_in_title_bar()
62
+    {
63
+        case "$BASH_COMMAND" in
64
+            *\033]0*)
65
+                # The command is trying to set the title bar as well;
66
+                # this is most likely the execution of $PROMPT_COMMAND.
67
+                # In any case nested escapes confuse the terminal, so don't
68
+                # output them.
69
+                ;;
70
+            *)
71
+                if test -n "${BASH_COMMAND}";
72
+                then
73
+                    echo -ne "\033]0;${BASH_COMMAND} (${PWD/$HOME/~})\007"
74
+                else
75
+                    echo -ne "\033]0;${PWD/$HOME/~}\$\007"
76
+                fi
77
+                ;;
78
+        esac
79
+    }
80
+    trap show_command_in_title_bar DEBUG
81
+    ;;
82
+esac