-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
v2ray
31 lines (28 loc) · 1.19 KB
/
v2ray
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# bash completion for v2ray/xray
function _auto_tab() {
local options_array=("start" "stop" "restart" "status" "update" "update.sh" "add" "del" "info" "port" "tls" "tfo" "stream" "iptables" "cdn" "stats" "clean" "log" "new" "rm" "-h" "-v" "help" "version")
local add_array=("wechat" "utp" "srtp" "dtls" "grpc" "wireguard" "socks" "mtproto" "ss" "vless_tcp" "vless_tls" "vless_ws" "vless_reality" "trojan" "ss" "quic" "h2" "tcp" "tcp_host" "ws" "vless_kcp" "vless_utp" "vless_srtp" "vless_dtls" "vless_wechat" "vless_wireguard" "vless_grpc")
local log_array=("access" "a" "error" "e")
local cur prev
compreply=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'v2ray')
compreply=( $(compgen -W "${options_array[*]}" -- $cur) ) ;;
'xray')
compreply=( $(compgen -W "${options_array[*]}" -- $cur) ) ;;
'add')
compreply=( $(compgen -W "${add_array[*]}" -- $cur) );;
'log')
compreply=( $(compgen -W "${log_array[*]}" -- $cur) );;
'stats')
compreply=( $(compgen -W "group user" -- $cur) );;
'iptables')
compreply=( $(compgen -W "show" -- $cur) );;
'*')
compreply=( $(compgen -d -f ${cur}) ) ;;
esac
return 0
}
complete -F _auto_tab v2ray xray