dotfiles

Dash Eclipse's dotfiles
git clone git://ezup.dev/dotfiles.git
Log | Files | Refs | README | LICENSE

commit af66c1c1dbaa223cbdf3ef5b8862195bf6922574
parent 862e643637e08bdb8cf3bf8d398f4b26e88b8f0c
Author: Dash Eclipse <dash@ezup.dev>
Date:   Sun, 27 Sep 2020 20:29:00 +0000

Update trt-fzf.sh and zsh completion for trt

Diffstat:
A.local/bin/trt | 2++
M.local/bin/trt-fzf.sh | 6++++--
A.local/share/zsh/site-functions/_trt | 2++
A.local/share/zsh/site-functions/_trt-fzf.sh | 17+++++++++++++++++
A.local/share/zsh/site-functions/_trt-json.sh | 24++++++++++++++++++++++++
5 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/.local/bin/trt b/.local/bin/trt @@ -0,0 +1 @@ +trt-fzf.sh+ \ No newline at end of file diff --git a/.local/bin/trt-fzf.sh b/.local/bin/trt-fzf.sh @@ -78,10 +78,12 @@ query_ipv6() { } url2csv() { + read -p "Type $(tput bold)Yes$(tput sgr0) to continue... " && [ $REPLY == "Yes" ] || { echo "$(tput bold; tput setaf 1)Canceled$(tput sgr0)"; exit 1; } : >$CSV # 1 2 3 4 5 6 7 8 9 10 #echo "password,remote_addr,remote_port,country_code,country_name,provider,number,time_appconnect,speed_download,ipv4" >>$CSV - total=$(cat $BASE64_URLS | base64 -d | wc -l) + BASE64_URLS=$(curl --progress-bar $TROJAN_SUBURL) + total=$(echo "$BASE64_URLS" | base64 -d | wc -l) local i=0 while IFS=, read -r password remote_addr remote_port mark; do local i=$(($i + 1)) @@ -101,7 +103,7 @@ url2csv() { echo "$i/$total | $country_code $provider $number | $time_appconnect $speed_download | $ipv4" echo "$password,$remote_addr,$remote_port,$country_code,$country_name,$provider,$number,$time_appconnect,$speed_download,$ipv4" >>$CSV sleep 2 - done < <(urldecode "$(curl -s "$TROJAN_SUBURL" | base64 -d | sed 's#^trojan://##' | sed 's/?allowInsecure=1&tfo=1//' | sed 's/@/,/; s/:/,/; s/#/,/')" | country_zh2code) + done < <(urldecode "$(echo "$BASE64_URLS" | base64 -d | sed 's#^trojan://##' | sed 's/?allowInsecure=1&tfo=1//' | sed 's/@/,/; s/:/,/; s/#/,/')" | country_zh2code) } switch_proxy() { diff --git a/.local/share/zsh/site-functions/_trt b/.local/share/zsh/site-functions/_trt @@ -0,0 +1 @@ +_trt-fzf.sh+ \ No newline at end of file diff --git a/.local/share/zsh/site-functions/_trt-fzf.sh b/.local/share/zsh/site-functions/_trt-fzf.sh @@ -0,0 +1,17 @@ +#compdef _trt trt +# +# Completion script for trt +# + +_trt() { + local -a subcmds + + fetch=('-f:Get csv') + select_node=('s:Select node') + client=('c:Switch node for trojan client') + nat=('n:Switch node for trojan NAT (root)') + reset=('r:Reset iptables rules (root)') + add=('a:Add iptables rules (root)') + + _describe 'command' fetch -- select_node -- client -- nat -- reset -- add +} diff --git a/.local/share/zsh/site-functions/_trt-json.sh b/.local/share/zsh/site-functions/_trt-json.sh @@ -0,0 +1,24 @@ +#compdef _trt trt +# +# Completion script for trt +# + +_trt() { + local -a subcmds + + levels=('global:List nodes by levels' 'bronze:List nodes by levels' 'silver:List nodes by levels' 'gold:List nodes by levels' 'platinum:List nodes by levels') + types=('time:List nodes by types' 'speed:List nodes by types' 'country:List nodes by types') + + switch_nat=('sn:Switch NAT node') + switch_client=('sc:Switch Client node') + + info=('i:Show info') + + update=('-u:Update IP list and json') + speedtest=('-t:Speed test') + + addrules=('-a:Add iptabels rules') + clearrules=('-c:Clear iptables rules') + + _describe 'command' levels -- types -- switch_nat -- switch_client -- info -- update -- speedtest -- addrules -- clearrules +}