0

I've got a few terminal themes that I use in my mac (the default terminal, not iterm or others) and I would like to know if there's a command line, API, or config file where I can check terminal's data. To be more specific, the current terminal theme's name.

I've tried to check if there's something in defaults command, and when I run defaults read com.apple.terminal I can see plenty of configs including the default theme in:

"Default Window Settings" = "...my theme...";

But not the theme(or themes) from the application that is running at the moment.

BTW: I've checked under /System/Applications/Utilities/Terminal.app/Contents but didn't found nothing yet.

Thanks / Any ideas?

0

1 Answer 1

1

This following AppleScript code will return the name of every theme currently being used in every Terminal window1.

tell windows of application "Terminal" to set themeNames to name of current settings

To run it from Terminal, simply run the following command:

osascript -e 'tell windows of application "Terminal" to return name of current settings'

It will return a comma-delimited list of the profile name for each open window in Terminal.


1 Since macOS High Sierra, tabs of a window in Terminal are treated as a window programmatically in AppleScript and therefore each physical window having multiple tabs can be using different themes. There will also be no grouping in the results, so e.g. one window having e.g. two tabs programmatically the two tabs are separate windows, not tabs like in macOS Sierra and earlier.

2
  • That's really helpful, now I'll look for a way to run this apple script from terminal and use the values. Thanks @wch1zpink
    – AndreDurao
    Commented Oct 19, 2021 at 22:39
  • 1
    Why the edit? The OP asked... "and use the values". Commented Oct 21, 2021 at 0:45

You must log in to answer this question.

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