File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -76,10 +76,33 @@ function _lazy_connect() {
7676EOF
7777}
7878
79+ function _lazy_connect_update() {
80+ lazy_connect_dir=~ /.lazy-connect
81+ seconds_in_7_days=$( echo $(( (7 * 24 ) * 3600 )) )
82+ commit_epoch=$( git -C $lazy_connect_dir log -1 --format=%cd --date=format:" %s" )
83+ now_epoch=$( date " +%s" )
84+ diff=$( echo $(( $now_epoch - $commit_epoch )) )
85+ if [ $diff -ge $seconds_in_7_days ]; then
86+ echo -n " Do you want to update lazy-connect?(y/n) "
87+ read input
88+ case $input in
89+ Y|y)
90+ echo " Updating..."
91+ git -C $lazy_connect_dir pull origin master
92+ ;;
93+ * )
94+ echo " Skipping update"
95+ ;;
96+ esac
97+ fi
98+ }
99+
79100function lazy-connect() {
80101 config_dir=~ /.config/lazy-connect
81102 mkdir -p $config_dir
82103
104+ _lazy_connect_update
105+
83106 while getopts " ih" opt; do
84107 case $opt in
85108 h)
@@ -107,4 +130,4 @@ function lazy-connect() {
107130 vpn_name=$( cat $config_dir /vpns \
108131 | fzf --height=10 --ansi --reverse)
109132 [ -z " $vpn_name " ] || _lazy_connect $vpn_name $secret
110- }
133+ }
You can’t perform that action at this time.
0 commit comments