Skip to content

Commit 415bb8f

Browse files
Merge pull request #10 from jskswamy/brew-install
Split src and exutable into different file
2 parents f3a3ebc + de8d9bf commit 415bb8f

File tree

1 file changed

+36
-35
lines changed

1 file changed

+36
-35
lines changed

lazy-connect.sh renamed to lazy-connect

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ function _lazy_connect_init() {
1515
echo 'Storing secret in keychain...'
1616
old_secret=~/.config/lazy-connect/secret
1717
[ -f "$old_secret" ] && rm "$old_secret"
18-
security delete-generic-password -a lazy-connect -s lazy-connect &> /dev/null
18+
security delete-generic-password -a lazy-connect -s lazy-connect &>/dev/null
1919
security add-generic-password -a lazy-connect -p "$secret_key" -s lazy-connect
2020
;;
2121
esac
2222
_lazy_connect_vpn_refresh
2323
}
2424

2525
function _lazy_connect_vpn_refresh() {
26-
local backup_file=/tmp/lazy-connect-vpns-`date +%-H-%M-%S-%F`
26+
local backup_file=/tmp/lazy-connect-vpns-$(date +%-H-%M-%S-%F)
2727
[ -f $_lazy_connect_config_dir/vpns ] && cp $_lazy_connect_config_dir/vpns $backup_file
2828
osascript <<EOF |
2929
tell application "System Events"
@@ -45,7 +45,7 @@ function _lazy_connect_vpn_refresh() {
4545
end tell
4646
end tell
4747
EOF
48-
tr ',' '\n' | sed 's/^[[:space:]]//g' > $_lazy_connect_config_dir/vpns
48+
tr ',' '\n' | sed 's/^[[:space:]]//g' >$_lazy_connect_config_dir/vpns
4949

5050
echo "Storing the VPN list..."
5151
if [ -f $backup_file ]; then
@@ -146,44 +146,45 @@ function lazy-connect() {
146146

147147
while getopts "iruh" opt; do
148148
case $opt in
149-
h)
150-
_lazy_connect_usage
151-
return 0
152-
;;
153-
i)
154-
_lazy_connect_init
155-
return 0
156-
;;
157-
r)
158-
echo "Refreshing VPN list..."
159-
_lazy_connect_vpn_refresh
160-
return 0
161-
;;
162-
u)
163-
_lazy_connect_update
164-
return 0
165-
;;
166-
\?)
167-
echo "Invalid Option: -$OPTARG."
168-
_lazy_connect_usage
169-
return 1
170-
;;
171-
:)
172-
echo "Option -$OPTARG requires an argument."
173-
_lazy_connect_usage
174-
return 1
175-
;;
149+
h)
150+
_lazy_connect_usage
151+
return 0
152+
;;
153+
i)
154+
_lazy_connect_init
155+
return 0
156+
;;
157+
r)
158+
echo "Refreshing VPN list..."
159+
_lazy_connect_vpn_refresh
160+
return 0
161+
;;
162+
u)
163+
_lazy_connect_update
164+
return 0
165+
;;
166+
\?)
167+
echo "Invalid Option: -$OPTARG."
168+
_lazy_connect_usage
169+
return 1
170+
;;
171+
:)
172+
echo "Option -$OPTARG requires an argument."
173+
_lazy_connect_usage
174+
return 1
175+
;;
176176
esac
177177
done
178178

179-
local secret=$(security find-generic-password -a lazy-connect -w 2> /dev/null | tr -d '\n')
180-
if [ -z "$secret" ];
181-
then
179+
local secret=$(security find-generic-password -a lazy-connect -w 2>/dev/null | tr -d '\n')
180+
if [ -z "$secret" ]; then
182181
echo "Secret not found in keychain. Initialize lazy-connect and try again."
183182
return 1
184183
fi
185184

186-
vpn_name=$(cat $_lazy_connect_config_dir/vpns \
187-
| fzf --height=10 --ansi --reverse --query "$*" --select-1)
185+
vpn_name=$(cat $_lazy_connect_config_dir/vpns |
186+
fzf --height=10 --ansi --reverse --query "$*" --select-1)
188187
[ -z "$vpn_name" ] || _lazy_connect "$vpn_name" "$secret"
189188
}
189+
190+
lazy-connect "$@"

0 commit comments

Comments
 (0)