diff --git a/lazy-connect.sh b/lazy-connect.sh index e1d8531..43df6d2 100755 --- a/lazy-connect.sh +++ b/lazy-connect.sh @@ -63,6 +63,7 @@ lazy-connect - Shell function to fuzzy search an IPSec VPN by name -u - Update lazy-connect -r - Refresh vpn list in ~/.config/lazy-connect -h - Show this help +-d - Disconnect a connected VPN EOF } @@ -105,7 +106,7 @@ function _lazy_connect() { esac fi - osascript <> "$_lazy_connect_config_dir/connected_vpns" +} + +function _lazy_disconnect() { + vpn_name=$1 + + osascript < $_lazy_connect_config_dir/connected_vpns } function _lazy_connect_update() { @@ -139,7 +168,7 @@ function lazy-connect() { local OPTIND mkdir -p $_lazy_connect_config_dir - while getopts "iruh" opt; do + while getopts "iruhd" opt; do case $opt in h) _lazy_connect_usage @@ -154,6 +183,11 @@ function lazy-connect() { _lazy_connect_vpn_refresh return 0 ;; + d) + vpn_name=$(cat $_lazy_connect_config_dir/connected_vpns | fzf --height=10 --ansi --reverse) + _lazy_disconnect "$vpn_name" + return 0 + ;; u) _lazy_connect_update return 0