0

Update: cloned to here: https://apple.stackexchange.com/q/460841/209336


I'd like to have a bash script along the lines of this:

# set terminal window profile to profile2
sleep 300
# set terminal window profile to profile1

during that sleep, I might go off and start using a different application than Terminal, or I might be using a different Window of Terminal. So the approaches which send a message to the active or front terminal window don't work. Can I grab the current terminal window ID at the start and re-use it later ?

orion elenzil
  • 4,484
  • 3
  • 37
  • 49

1 Answers1

1

You can use tty to identify the window.

Save following script to test.sh and run it with bash test.sh

#!/usr/bin/env bash

osascript -e 'tell application "Terminal" to set current settings of (the first window whose tty of tab 1 contains "'"$(tty)"'") to settings set "Basic"'

echo "You can switch to another windows"

sleep 6

osascript -e 'tell application "Terminal" to set current settings of (the first window whose tty of tab 1 contains "'"$(tty)"'") to settings set "Grass"'
Philippe
  • 20,025
  • 2
  • 23
  • 32