Add VPN code
This commit is contained in:
2
completions/bash/mtm-ssh-proxy
Normal file
2
completions/bash/mtm-ssh-proxy
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
|
||||
49
completions/bash/mtm-ssh-vpn
Normal file
49
completions/bash/mtm-ssh-vpn
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
_mtm-ssh-vpn() {
|
||||
# shellcheck disable=SC2034
|
||||
local cur prev words cword args
|
||||
_init_completion || return
|
||||
|
||||
local -r CNF_ARGS="--help"
|
||||
local -r CMD_ARGS="status connect disconnect disconnect-all"
|
||||
local -r PROFILE_DIR=~/.config/mtm-ssh-proxy
|
||||
local -r TMP_DIR="/tmp/mtm-ssh-proxy-${USER}/vpn"
|
||||
|
||||
if [[ ${COMP_WORDS[*]} == *"--help"* ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
args=${CMD_ARGS}
|
||||
for arg in ${CNF_ARGS}; do
|
||||
if [[ ${COMP_WORDS[*]} != *"${arg}"* ]]; then
|
||||
args+=" ${arg}"
|
||||
fi
|
||||
done
|
||||
for arg in ${CMD_ARGS}; do
|
||||
if [[ ${COMP_WORDS[*]} == *" ${arg} "* ]]; then
|
||||
args=""
|
||||
fi
|
||||
done
|
||||
|
||||
case $prev in
|
||||
--help | status | disconnect_all) return;;
|
||||
connect)
|
||||
local -r PROFILELIST=$(\ls "${PROFILE_DIR}")
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "${PROFILELIST}" -- "${COMP_WORDS[COMP_CWORD]}"))
|
||||
return
|
||||
;;
|
||||
disconnect)
|
||||
local -r PROFILELIST=$(\ls "${TMP_DIR}")
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "${PROFILELIST}" -- "${COMP_WORDS[COMP_CWORD]}"))
|
||||
return
|
||||
;;
|
||||
*)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "${args}" -- "${COMP_WORDS[COMP_CWORD]}"))
|
||||
return
|
||||
;;
|
||||
esac
|
||||
} && complete -F _mtm-ssh-vpn mtm-ssh-vpn
|
||||
Reference in New Issue
Block a user