Skip to main content
added 426 characters in body
Source Link
Lri
  • 106.4k
  • 19
  • 230
  • 283

You can use AppleScriptTo close all windows except the frontmost window, run:

osascript -e 'tell app "Google Chrome" to close (windows 2 thru -1)'

What you call instancesTo close all windows except the window opened first, run a script like this in AppleScript Editor:

tell application "Google Chrome"
    if number of windows < 2 then return
    set min to id of window 1
    repeat with w in windows 2 thru -1
        if id of w < min then set min to id of w
    end repeat
    close (windows where id is not min)
end tell

"Instances" are usually called windows in OS X. Windows, and windows are not separate instances of a process like the instances opened by open -n.

You can use AppleScript:

osascript -e 'tell app "Google Chrome" to close (windows 2 thru -1)'

What you call instances are usually called windows in OS X. Windows are not separate instances of a process like the instances opened by open -n.

To close all windows except the frontmost window, run:

osascript -e 'tell app "Google Chrome" to close (windows 2 thru -1)'

To close all windows except the window opened first, run a script like this in AppleScript Editor:

tell application "Google Chrome"
    if number of windows < 2 then return
    set min to id of window 1
    repeat with w in windows 2 thru -1
        if id of w < min then set min to id of w
    end repeat
    close (windows where id is not min)
end tell

"Instances" are usually called windows in OS X, and windows are not separate instances of a process like the instances opened by open -n.

Source Link
Lri
  • 106.4k
  • 19
  • 230
  • 283

You can use AppleScript:

osascript -e 'tell app "Google Chrome" to close (windows 2 thru -1)'

What you call instances are usually called windows in OS X. Windows are not separate instances of a process like the instances opened by open -n.