mac scripts

发布时间 2023-04-06 18:40:41作者: ploolq
#!/bin/bash
osascript <<EOD
tell application "Finder"
   if (get count of windows) ≥ 2 then
      close (get every window whose index is not 1)
   end if
end tell
#!/bin/bash
osascript <<EOD
tell application "System Events" to keystroke "q" using {control down, command down}
#!/bin/bash
osascript <<EOD
tell application "Finder"
     if (get count of windows) ≥ 3 then
         activate
         set visible to true
         activate
     else
         make new Finder window to home
         activate
         set visible to true
         activate
     end if
end tell
#!/bin/bash
osascript <<EOD
tell application "iTerm"
     activate
     if (get count of windows) ≥ 1 then
         activate
            set visible to true
         activate
     else
         create window with default profile
         activate
         set visible to true
         activate
     end if
end tell
activate application "SystemUIServer"
tell application "System Events"
    tell process "SystemUIServer" to keystroke "q" using {command down, control down}
end tell


#!/bin/bash
osascript <<EOD
tell application "Visual Studio Code"
    set theWindows to windows

    repeat with aWindow in theWindows
        if (name of aWindow) contains "myTerminalWindow" then
            display dialog ("Will not close " & name of aWindow)
        else
            set theProcesses to processes of aWindow
            set clean commands of current settings of aWindow to theProcesses
            close aWindow without saving
        end if
    end repeat

end tell