Archived
1
0

Add bash completion

This commit is contained in:
MatMoul 2025-08-21 03:46:04 +02:00
parent 24124c1308
commit 0d5cf8f506

45
completion/bash/ssh-proxy Normal file
View File

@ -0,0 +1,45 @@
#!/bin/bash
_ssh-proxy() {
# shellcheck disable=SC2034
local cur prev words cword args
_init_completion || return
local -r cmdargs="start stop"
local -r cnfargs="--help"
local profiledir=~/.config/ssh-proxy
#local tempdir="/tmp/ssh-proxy-${USER}"
if [[ ${COMP_WORDS[*]} == *"--help"* ]]; then
return
fi
args=${cmdargs}
for arg in ${cnfargs}; do
if [[ ${COMP_WORDS[*]} != *"${arg}"* ]]; then
args+=" ${arg}"
fi
done
for arg in ${cmdargs}; do
if [[ ${COMP_WORDS[*]} == *" ${arg} "* ]]; then
args=""
fi
done
case $prev in
--help)
return
;;
start | stop)
local -r PROFILELIST=$(\ls ${profiledir})
# 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 _ssh-proxy ssh-proxy