Archived
1
0
This repository has been archived on 2025-08-30. You can view files and clone it, but cannot push or open issues or pull requests.
2025-08-24 19:36:55 +02:00

54 lines
1.1 KiB
Bash

#!/bin/bash
_ssh-proxy() {
# shellcheck disable=SC2034
local cur prev words cword args
_init_completion || return
local -r cmdargs="status start stop startall stopall"
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
;;
status | startall | stopall)
return
;;
start)
local -r PROFILELIST=$(\ls ${profiledir})
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${PROFILELIST}" -- "${COMP_WORDS[COMP_CWORD]}"))
return
;;
stop)
local -r PROFILELIST=$(\ls ${tempdir})
# 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