Skip to content

Instantly share code, notes, and snippets.

@armand1m
Created April 20, 2016 03:22
Show Gist options
  • Save armand1m/4146623195ab1a9a7118e8dfa2b92b4d to your computer and use it in GitHub Desktop.
Save armand1m/4146623195ab1a9a7118e8dfa2b92b4d to your computer and use it in GitHub Desktop.
.bash_profile with functions for connecting to vpn using AppleScript
function vpn-connect {
/usr/bin/env osascript <<-EOF
tell application "System Events"
tell current location of network preferences
set VPN to service "your-vpn-name"
if exists VPN then connect VPN
repeat while (current configuration of VPN is not connected)
delay 1
if exists VPN then connect VPN
end repeat
end tell
end tell
EOF
}
function vpn-disconnect {
/usr/bin/env osascript <<-EOF
tell application "System Events"
tell current location of network preferences
set VPN to service "your-vpn-name"
if exists VPN then disconnect VPN
end tell
end tell
return
EOF
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment