1

I'm trying to programmatically query the background color of my terminal with

echo -ne "\e]11;?\a"

but the output appears blank. The issue arises using both Terminal.app and iTerm 3, in both Zsh and Bash, using any number of color schemes. When I redirect the output to a file instead, opening the file in Vi with vi -u None, I see the following:

^[]11;?^G

The value of TERM is xterm-256color.

What's going on here? How can I get my terminal background color and why isn't the query sequence working?

6
  • The trailing ` should be the problem. Nov 14, 2016 at 19:48
  • @IporSircer no, that was just a typo writing the post Nov 14, 2016 at 19:53
  • Redirecting echo's output does not do what you expect. It literally redirects the exact same string you pass to echo, without it ever hitting the terminal emulator. The intended behavior (as Thomas said, implemented by some terminals) is that you send this to the terminal, and in turn, the terminal responds as if the user typed the response from the keyboard, which your app will receive as input. See also xtermcontrol(1).
    – egmont
    Nov 15, 2016 at 0:23
  • Just for reference: the feature request for iTerm is here: gitlab.com/gnachman/iterm2/issues/4953.
    – egmont
    Nov 15, 2016 at 0:28
  • @egmont I was under the impression that it had been developed and merged, but I realize now that it's for v3.2 instead of 3.0.whatever that I have installed. Nov 15, 2016 at 2:03

2 Answers 2

2

That's one of several xterm features implemented by some other terminals. Neither of the terminals you mentioned implements this, so far.

Neither is an X application, but this may help:

2
  • This page is a great learning resource. However the real answer is in the comments: "this feature hasn't been released yet", whereas I was under the impression that it had been. Nov 15, 2016 at 2:50
  • The cited issue says more than that: it hasn't been written yet. Nov 15, 2016 at 8:55
0

As per the comments, a feature request exists for this question. I had seen that feature request, but I was under the mistaken impression that the feature was already incorporated into the latest stable release.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .