Linux – GNOME Terminal – process name in tab title

gnomelinuxterminal

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

— UPDATE —

To clarify, I want the tab title to update when I run a process, for example:

# title is currently "bash"
$ find / -name foo # while searching for foo, title is "find"
$ # title is once again "bash"
$ less /proc/cpuinfo # title changes to "less"
$ man ls # title changes to man
$ # title returns to "bash"

Best Answer

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.

Related Question