I'm using Gnome on Ubuntu. I often have 8-20 terminal sessions open and in some of them I have su'd to a different user. The specific problem that caused me to write this query happens when using git status, but this is more general issue. git status will tell me I have an uncontrolled file .foo.java.swp. This means that in one of my terminal sessions I have vi open on foo.java.

I need a script or tool that would tell me in which terminal session that vi is running. I can do a "ps aux | grep vi" to pretty easily find the pid of the particular vi. It would be nice if the tool highlighted the terminal on my task bar in some way.



  • 1
    Did you consider using screen ? – WilQu Oct 28 '11 at 15:48
  • Never heard of screen. Just read the man page of byobu, the screen wrapper on Ubuntu. It looks too heavyweight for my intermittent problem -- I'd have to give up two lines at the bottom of my monitor). – Sam Oct 28 '11 at 16:32
  • 1
    With screen by itself, you give up nothing. Messages can be displayed over the last line or even in the windows title (hardstatus) - or you can give up some lines if you like. It is only when you split the terminal (vertically or horizonally) that you are required to give up a line (for each pane). – Arcege Oct 28 '11 at 18:38

Each of your terminal windows will have a different pseudoterminal assigned, as accessible by the tty command. You can cross-reference this with the TTY column of your ps u output. For GUI integration, I usually found it sufficient to add the current pty identifier to my terminal's window title using xtitle, like

if [ "$PS1" ] ; then
  xtitle xterm $(tty)

Jumping to a window by title is easy in my window manager, no idea about GNOME.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy