Skip to content

Commit

Permalink
优化命令补全
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrohy committed Dec 10, 2020
1 parent 44cf2b7 commit 7abe0b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
6 changes: 4 additions & 2 deletions v2ray
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# bash completion for v2ray
# 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")
local add_array=("wechat" "utp" "srtp" "dtls" "wireguard" "socks" "mtproto" "ss" "vless" "vless_ws" "vless_xtls" "trojan" "ss" "quic" "h2" "tcp" "tcp_host" "ws")
Expand All @@ -12,6 +12,8 @@ function _auto_tab() {
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')
Expand All @@ -22,4 +24,4 @@ function _auto_tab() {

return 0
}
complete -F _auto_tab v2ray
complete -F _auto_tab v2ray xray
7 changes: 1 addition & 6 deletions v2ray.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,7 @@ updateProject() {

#更新v2ray bash_completion脚本
curl $BASH_COMPLETION_SHELL > /usr/share/bash-completion/completions/v2ray
curl $BASH_COMPLETION_SHELL > /usr/share/bash-completion/completions/xray
sed -i 's/v2ray/xray/g' /usr/share/bash-completion/completions/xray
if [[ -z $(echo $SHELL|grep zsh) ]];then
source /usr/share/bash-completion/completions/v2ray
source /usr/share/bash-completion/completions/xray
fi
[[ -z $(echo $SHELL|grep zsh) ]] && source /usr/share/bash-completion/completions/v2ray

#安装V2ray主程序
[[ ${INSTALL_WAY} == 0 ]] && bash <(curl -L -s https://multi.netlify.app/go.sh)
Expand Down

0 comments on commit 7abe0b5

Please sign in to comment.