2012-05-11 6 views
2

現在実行中のプロセス名をGNOMEターミナルタブのタイトル(またはタブが1つのみの場合はタイトルバー)に入れるにはどうすればよいですか?ターミナルエミュレータタブまたはタイトルバーでプロセス名を表示する方法

https://superuser.com/questions/42362/gnome-terminal-process-name-in-tab-titleは解決策(下記)を提供しますが、開始時に各タブをゴミで完全に壊してしまいます。より良い方法がありますか?

case "$TERM" in 
xterm*|rxvt*) 
    set -o functrace 
    trap 'echo -ne "\e]0;$BASH_COMMAND\007"' DEBUG 
    PS1="\e]0;\s\007$PS1" 
    ;; 
*) 
    ;; 
esac 

答えて

3

誰もがすでにDavid Pashleyの解決策を知っているようだから、私はこれを見つけ出すのにずっと時間がかかりました。 これは実際にbash-completion問題を処理します。

明確にする:私はここだけで何もしなかった。すべてのクレジットはMarius Gedminas(http://mg.pov.lt/blog/bash-prompt.html)に送られます。

これはgnome-terminalの/ターミネーター

# If this is an xterm set the title to [email protected]:dir 
case "$TERM" in 
xterm*|rxvt*) 
    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' 

    # Show the currently running command in the terminal title: 
    # http://www.davidpashley.com/articles/xterm-titles-with-bash.html 
    show_command_in_title_bar() 
    { 
     case "$BASH_COMMAND" in 
      *\033]0*) 
       # The command is trying to set the title bar as well; 
       # this is most likely the execution of $PROMPT_COMMAND. 
       # In any case nested escapes confuse the terminal, so don't 
       # output them. 
       ;; 
      *) 
       echo -ne "\033]0;${USER}@${HOSTNAME}: ${BASH_COMMAND}\007" 
       ;; 
     esac 
    } 
    trap show_command_in_title_bar DEBUG 
    ;; 
*) 
    ;; 
esac 
と私のために完璧に動作
関連する問題