Depending on what exactly you want to accomplish, here's a few ideas in AppleScript using your Terminal styles. These are more robust than tput
, because this gets reset by colored prompts. etc (at least for me).
This sets all tabs running Python (no SSH server available for testing right now) to Homebrew, the others to Ocean:
tell application "Terminal"
repeat with w from 1 to count windows
repeat with t from 1 to count tabs of window w
if processes of tab t of window w contains "Python" then
set current settings of tab t of window w to (first settings set whose name is "Homebrew")
else
set current settings of tab t of window w to (first settings set whose name is "Ocean")
end if
end repeat
end repeat
end tell
save as script and run as osascript Name.scpt
anytime you want to re-color your shells (of course you can wrap this as a shell script or something).
If you want to display all long-running processes differently, use the following condition:
if busy of tab t of window w is true then
Or, you can set the style of a single tab, manually selected:
on run argv
tell application "Terminal" to set current settings of tab (item 1 of argv as number) of front window to first settings set whose name is (item 2 of argv)
end run
Run it like this:
osascript StyleTerm.scpt 3 Homebrew
-> Third tab of frontmost Terminal window gets Homebrew style!
If you want to modify background windows, replace "front window" with a parenthesized expression like just after "tab".
If you always want to modify the selected "current tab", use selected tab
instead of tab (item 1 of argv as number)
.
Add the following to your .bash_profile
if the first solution is too manual labour for you:
PROMPT_COMMAND='osascript "/path/to/Name.scpt"'
Now it gets executed before every prompt (only problem: not after starting something, i.e. ssh
. But this topic isn't about fancy bash tricks anyway. This is just a pointer.)
Open a Command Prompt, click the icon (top-left), select Properties.
Choose Colors, adjust to taste. It will ask you if you want to save the colour for future settings - choose yes.
Best Answer
You can create an AppleScript script to change the colors of the current Terminal tab. You can use the Script Editor found in Applications/Utilities to create the script. One way to change the colors is to use the color schemes that you could manually select for the Terminal window, but perform the selection in a script. E.g., you could create a script with the following commands using the Script Editor
You could substitute "grass", "ocean", "Red Sands", etc., instead of "novel". Inside the Script Editor click on File and then select Save. Save the script wherever you wish to place it as a .scpt file. Assuming you named the file terminal-colors and placed it your ~/Documents directory, from a Terminal window tab, you can run the script using the osascript command
osascript ~/Documents/terminal-colors.scpt
Alternatively, you can set specific background colors of your choosing using values you can find for specific colors at colors.csv. E.g., if you wanted to have a hot pink background, you could use the following commands in your script, instead of the ones above:
This is an OSX/MacOS solution that wouldn't be portable to Linux/Unix.
You can see other settings you can change for a Terminal window by opening the Terminal "dictionary" in the Script Editor. Click on File, select Open Dictionary, scroll through the list of dictionaries until you see Terminal.app then click on it to select it and then click on the Choose button. Within the dictionary, click on Terminal Suite then tab to see settings you can change for individual Terminal window tabs.