Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View kevin-funderburg's full-sized avatar
😆

Kevin Funderburg kevin-funderburg

😆
View GitHub Profile
set device to do shell script "networksetup -listallhardwareports | awk '$3==\"Wi-Fi\" {getline;print}' | awk '{print $2}'"
set power to do shell script "networksetup -getairportpower " & device & " | awk '{print $4}'"
if power is equal to "on" then
set power to "off"
else
set power to "on"
end if
do shell script ("networksetup -setairportpower " & device & " " & power)
@kevin-funderburg
kevin-funderburg / quicktime-toggle-screen-recording.applescript
Created May 15, 2019 20:36
Useful script to toggle on and off a quicktime screen recording.
tell application "QuickTime Player"
set check to name of every window
if check is {} then
set resultDocument to new screen recording
tell resultDocument
delay 1
start
end tell
else
set resultDocument to first document whose name is "Screen Recording"
@kevin-funderburg
kevin-funderburg / scriptDebugger-duplicate-tab.applescript
Created May 15, 2019 20:42
Duplicate the front tab in Script Debugger.
tell application "Script Debugger"
tell front document
set sourceText to source text
set thename to name
end tell
set d to make new document with properties {source text:sourceText}
tell d
compile
end tell
end tell
@kevin-funderburg
kevin-funderburg / toggle-bluetooth.applescript
Created May 15, 2019 20:46
Toggle bluetooth on and off.
tell application "System Events" to tell process "SystemUIServer"
set bt to (first menu bar item whose description is "bluetooth") of menu bar 1
click bt
tell menu of bt
if exists menu item "Turn Bluetooth On" then
click menu item "Turn Bluetooth On"
else if menu item "Turn Bluetooth Off" exists then
click menu item "Turn Bluetooth Off"
else
key code 53 --escape
@kevin-funderburg
kevin-funderburg / paste-safari-title-with-link.applescript
Last active May 15, 2019 20:52
Very useful, pastes the title of the front Safari window with the link to the page embedded.
@kevin-funderburg
kevin-funderburg / open-front-folder-in-iterm.applescript
Last active May 15, 2019 21:44
Open current Finder folder in iTerm2
tell application "Finder"
set myWin to window 1
set theWin to (quoted form of POSIX path of (target of myWin as alias))
end tell
tell application "iTerm"
set w to create window with profile "Default"
tell w's current session to write text "cd " & theWin & " && clear"
end tell
@kevin-funderburg
kevin-funderburg / close-unsaved-documents-of-front-app.applescript
Created May 15, 2019 21:49
Closes all the un-saved documents of the front app.
-- Note: This works in all the apps I’ve tried it in, so there may be others it doesn't
tell application "System Events" to set frontapp to name of first process whose frontmost is true
tell application frontapp
activate
repeat with i from (count of documents) to 1 by -1
set thisDocument to document i
try
if path of (get properties of thisDocument) = missing value or name of thisDocument contains "Untitled" then
@kevin-funderburg
kevin-funderburg / close-all-documents-with-saving.applescript
Created May 15, 2019 21:52
Save and close all open documents of front app.
tell application "System Events" to set frontapp to name of first process whose frontmost is true
tell application frontapp to close every document with saving
@kevin-funderburg
kevin-funderburg / close-all-documents-without-saving.applescript
Created May 15, 2019 21:55
Close all documents of front app without saving.
tell application "System Events" to set frontapp to name of first process whose frontmost is true
tell application frontapp to close every document without saving
@kevin-funderburg
kevin-funderburg / close-document-with-saving.applescript
Created May 15, 2019 21:57
Close front document of front app with saving.
tell application "System Events" to set frontapp to name of first process whose frontmost is true
tell application frontapp
tell front document
close saving yes
end tell
end tell