Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i find out the current osx-terminal theme from within a bash script

Inside a bash script, I need to know what the current OS X terminal theme is. How can this be done?

I check the output of the env command, but didn't find anything.

like image 327
american-ninja-warrior Avatar asked Oct 29 '25 14:10

american-ninja-warrior


1 Answers

We can use an AppleScript to retrieve the name of the profile of the foremost Terminal window from within a bash shell:

echo 'tell application "Terminal" to return name of current settings of first window' | osascript

We can similarly set the profile:

echo 'tell application "Terminal" to set current settings of first window to settings set "Basic"' | osascript

Replace "Basic" with the name of the profile you wish to adopt.

These commands will apply to the current/foremost tab or window of Terminal.app

I've also written a script that will get/set the profile depending on whether a profile name is provided: https://github.com/starbase527/dotfiles/blob/master/local/bin/term-profile . Example usage:

# Gets profile name
> term-profile
Basic
# Sets profile to Basic
> term-profile Basic
>
like image 127
Jasper Avatar answered Oct 31 '25 04:10

Jasper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!