I have this code that sends a specific command to all tabs including the current one, in iTerm2. But, sometimes, some tabs are stuck and I want to get them to a shell prompt before trying to execute the command. However, sending Ctrl+C to the current tab, will stop the script from continuing.
I want to send the kill signal to all other tabs but not the current one.
osascript \
-e 'tell application "iTerm"' \
-e " tell current window" \
-e ' repeat with aTab in tabs' \
-e ' tell aTab' \
-e ' repeat with asession in sessions' \
-e ' tell asession' \
-e ' tell application "System Events" to keystroke "c" using {control down}' \
-e ' end tell' \
-e ' end repeat' \
-e ' end tell' \
-e ' end repeat' \
-e ' end tell' \
-e 'end tell'
I tried conditioning "tell aTab" with "if aTab is not equal current tab", but that still didn't work.