Skip to content

Instantly share code, notes, and snippets.

@pjjw
Forked from SamRaymer/FireMiddleFingerITerm.scpt
Created January 5, 2011 00:28
Show Gist options
  • Save pjjw/765717 to your computer and use it in GitHub Desktop.
Save pjjw/765717 to your computer and use it in GitHub Desktop.
set myHost to "a host you have ssh access to"
set userName to "your username on said host"
set socksPort to 8080
tell application "iTerm"
activate
set openProxy to false
repeat with curTerm in terminals
repeat with curSesh in curTerm's sessions
if curSesh's name is "FireMiddleFinger" then
set openProxy to true
end if
end repeat
end repeat
-- make a new terminal
set myterm to current terminal
if not openProxy then
-- talk to the new terminal
tell myterm
-- make a new session
set mysession to (make new session at the end of sessions)
-- talk to the session
tell mysession
-- set some attributes?
-- execute a command
exec command "/bin/zsh --login"
write text "ssh " & userName & "@" & myHost & " -D " & socksPort & " 2> /dev/null"
set the name of mysession to "FireMiddleFinger"
end tell -- we are done talking to the session
end tell
end if
end tell
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.network"
end tell
tell application "System Events"
get properties
tell process "System Preferences"
tell window "Network"
-- Selects the active network connection
tell table 1 of scroll area 1
click row 1
end tell
--Select the Advanced button
click button 11
--Select the Proxies tab
tell tab group 1 of sheet 1
-- delay 1
click radio button 6
tell group 1
tell table 1 of scroll area 1
set selected of row 6 to true
click checkbox of row 6
if value of (checkbox 1 of row 6) is 1 then
set outStr to "You Turned SOCKS ON"
else
set outStr to "You Turned SOCKS OFF"
end if
end tell
end tell
end tell
tell sheet 1
click button "OK"
end tell
end tell
tell window "Network"
click button "Apply"
end tell
end tell
end tell
tell application "System Preferences"
quit
end tell
-- Voice status of SOCKS Proxy settings
say outStr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment