diff --git a/README.md b/README.md index f9fb84b..0bb7f6e 100644 --- a/README.md +++ b/README.md @@ -31,11 +31,12 @@ sudo ln -s ~/.lazy-connect/lazy-connect /usr/local/bin/lazy-connect ``` lazy-connect - Shell function to fuzzy search an IPSec VPN by name - and connect to it automatically. + and connect/disconnect to it automatically. -i - Initialize lazy-connect. Stores the TOTP secret and VPN list. -r - Refresh vpn list in ~/.config/lazy-connect . -n - Do not fill the password automatically. Instead copy the password to clipboard. +-y - Connect/disconnect automatically to the last connected VPN without prompt. -h - Show this help. ``` diff --git a/lazy-connect b/lazy-connect index 81b40b0..8733516 100755 --- a/lazy-connect +++ b/lazy-connect @@ -45,7 +45,7 @@ function _lazy_connect_vpn_refresh() { end tell end tell EOF - tr ',' '\n' | sed 's/^[[:space:]]//g' >$_lazy_connect_config_dir/vpns + tr ',' '\n' | sed 's/^[[:space:]]//g' | cut -d' ' -f2- >$_lazy_connect_config_dir/vpns echo "Storing the VPN list..." if [ -f $backup_file ]; then @@ -66,6 +66,7 @@ lazy-connect - Shell function to fuzzy search an IPSec VPN by name -i - Initialize lazy-connect. Stores the TOTP secret and VPN list. -r - Refresh vpn list in ~/.config/lazy-connect . +-y - Select the last selected VPN. -n - Do not fill the password automatically. Instead copy the password to clipboard. -h - Show this help. EOF @@ -134,14 +135,15 @@ function _lazy_connect() { end tell end tell end connectVpn - connectVpn("$vpn_name", "$password", "$autofill") EOF } function _lazy_connect_mojave() { vpn_name=$1 - osx_vpn_name="${vpn_name/Connect /}, Not Connected" + osx_vpn_name_not_connected="${vpn_name/Connect /}, Not Connected" + osx_vpn_name_connected="${vpn_name/Connect /}, Connected" + osx_vpn_name="${vpn_name/Connect /}" _lazy_connect_get_totp $2 local autofill=$3 @@ -162,47 +164,52 @@ function _lazy_connect_mojave() { fi osascript < $_lazy_connect_config_dir/last_vpn } lazy-connect "$@"