I am writing a program to dynamically change all of my terminals (atm, it's URXVT) foreground color via OSC escape sequences. As a result, I have to sent the command to the currently open terminals for the command to apply.

The end goal is for this to quietly run in the background and run every minute or so (the color is picked from a background image which changes every minute), so things like xdotool don't work, as they send keystrokes to the terminal.

I tried ttyecho, but it seems to only work on the terminal it's run in, even if you specify otherwise.

Anyone know a solution to my problem? I'm not dependent on OSC, it's just the only way I've found to update the terminal colors without restarting them, so other methods are acceptable.

  • Can't think of any method except changing the URXVT source code so it'll pick up the foreground color from some location at a certain interval, without escape sequences. And I am not daring to ask why you need this.
    – dirkt
    Jul 7, 2019 at 5:20

1 Answer 1


Figure out the name of the terminal line, e.g. by executing the tty command in the given terminal. It'll report something like /dev/pts/5.

Then from anywhere (e.g. another terminal, or even a shell script running without a terminal) execute a command like this:

printf [the OSC sequence] > /dev/pts/5

Note that there's a slim chance that if another process is producing output in the given terminal then these two will conflict (interrupt each other, resulting in garbage instead of the app's and OSC's desired outcome).

  • That would be what I am looking for! Thank you! Good to know you can just pipe commands to /dev/pts like that. Jul 7, 2019 at 13:25

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.