Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm running Ubuntu Linux. I have two open Terminal windows running side by side. I'm looking to be able to hit the enter key once, and have that key stroke sent to both windows.

(What I'm doing is stepping through some code on two different systems using a debugger, and I don't want to have to keep switching back and forth between the windows as I step through the code.)

Thanks!

share|improve this question

4 Answers 4

I don't see an easy way to do this while inside one of your debugging windows, but you could use a third windows running a script that wrapped around xvkbd. It's in the ubuntu repository (might be in universe). The script could read your keyboard input and then call xvkbd twice, sending the keystrokes to both windows. Normally a graphical program, using

xvkbd -window xterm2 -text $foo

sends key events to specific windows, but doesn't invoke a UI. You also might find that wmctrl helps identify windows & stuff. A simplistic script might be:

#!/bin/bash

while [ 1 ]; do
    wmctrl -i -a 0x02200003   #forcibly set focus in window running script
    read keys
    xvkbd -window 0x2202ea4 -text "$keys\r"
    xvkbd -window 0x2200084 -text "$keys\r"
done
share|improve this answer
    
1 = 1 is not necessary, while [ 1 ] does the same thing :P –  John T Dec 13 '09 at 6:09
    
I used this approach to control two Evince windows displaying two versions of the same PDF document. For some reason one of the windows missed about every 10th keystroke. I couldn't figure out why that was. –  akaihola Feb 10 '10 at 9:57

The Terminator application (not to be confused by a Java application with the same name) provides exactly the functionality you need. You can install it from Ubuntu's repositories with apt-get install terminator.

Here's how it works:

  • run Terminator
  • open multiple sessions in tabs or frames
  • click the button at the top left corner of a frame
  • select the "New group..." menu item
  • type a name for the group
  • in each session you want to send keystrokes to, select that group from the menu
  • you can use the "Broadcast group" and "Broadcast off" menu items to toggle broadcasting keystrokes.

There are also keyboard shortcuts for this.

share|improve this answer

You'd not be able to do that in GNOME Terminal, IIRC.

If you'd like to try Konsole, there's a Send Input to All Sessions option in Konsole 3, which becomes Copy Input to... in Konsole 4.

share|improve this answer
    
I tested ny example script in gnome-terminal. worked ok. –  DaveParillo Dec 14 '09 at 1:51
    
With the built-in fuctions of GNOME Terminal, I mean. :-) –  0x44 Dec 14 '09 at 4:42

Use keyboardcast, which is designed for this.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.