Home » Questions » Computers [ Ask a new question ]

GNOME Terminal - process name in tab title

GNOME Terminal - process name in tab title

How can I put the current running process name into a GNOME Terminal tab title (or title bar when there's only one tab)?

Asked by: Guest | Views: 175
Total answers/comments: 2
Guest [Entry]

"Found it. This site provides a good explanation of a solution.
In your bashrc, it would look like:

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

Personally, I don't think I would add it to my bashrc, because the DEBUG combined with trace does throw out a load of garbage when all your shell starts. If you can live with that, it actually does work. It does display the entire command, however, not just the first word."
Guest [Entry]

"The below should work. I have the function in a .bash_functions file, and source it in the .bashrc file before setting $PROMPT_COMMAND.

function term_title
{
history 1 | awk '{print $2}';
}

PROMPT_COMMAND='echo -ne ""\033]0;""$(term_title)""\007""'"