0

When I attempt to restore a MacOS terminal window's default color by executing the following:

osascript -e "tell application \"Terminal\" to set current settings of window 1 to settings set \"Homebrew\""

the Terminal background color is restored to the Homebrew default, but not the foreground color. Doing it explicitly also has no effect:

osascript -e 'tell application "Terminal" to set normal text color of window 1 to {47802, 61423, 16448, 0}'

Oddly, when I execute an ls (LSCOLORS are on) immediately after the above, colors are restored to the correct state. Any idea what might be going on or how to fix it?

Also, there's nothing in the PS string to change the color as part of the prompt. Hitting return a couple times has no effect. Neither does executing something harmless like echo. Thanks!

1 Answer 1

0

This is interesting, because I cannot reproduce your error. What system are you running ? For reference, here are my relevant system details:

System info: AppleScript version: "2.7", system version: "10.13.6" (High Sierra)

One thing to note, is that current settings and normal text color are properties that are ascribed to tabs of Terminal, and not windows. Therefore, one thing you could try is:

osascript -e "tell application \"Terminal\" to ¬
          set current settings of tab 1 of window 1 to ¬
          settings set \"Homebrew\""

However, if I'm being honest, I'm not expecting this to solve your problem, since your piece of code works just fine on my system.

1
  • As expected, Didn't work :-) (It's also AS 2.7 on 10.13.6) I did track things down a bit more. The color change is in a function that changes colors, ssh's into a remote system, and then when ssh terminates, restores the colors. The remote system's shell does mess with the colors in its PS2 variable (which is why I want to put them back). I found that if I remove the color changes from the remote system PS2, that things work correctly, so it seems to be some odd interaction with ssh.
    – aholub
    Sep 7, 2018 at 0:37

You must log in to answer this question.

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