Skip to content

Commit

Permalink
refactor: optimize IP display (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
mouyase authored Nov 30, 2020
1 parent 9ef5b5b commit f0f9d2b
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions zsh-proxy.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,27 @@ __check_ip() {
echo "========================================"
echo "Check what your IP is"
echo "----------------------------------------"
echo -n "IPv4: "
curl -s -k https://api-ipv4.ip.sb/ip
ipv4=$(curl -s -k https://api-ipv4.ip.sb/ip)
if [[ "$ipv4" != "" ]]; then
echo "IPv4: $ipv4"
else
echo "IPv4: -"
fi
echo "----------------------------------------"
echo -n "IPv6: "
curl -s -k https://api-ipv6.ip.sb/ip

ipv6=$(curl -s -k https://api-ipv6.ip.sb/ip)
if [[ "$ipv6" != "" ]]; then
echo "IPv6: $ipv6"
else
echo "IPv6: -"
fi
if command -v python >/dev/null; then
echo ""
echo "----------------------------------------"
echo "Info: "
curl -s -k https://api.ip.sb/geoip | python -m json.tool
echo ""
geoip=$(curl -s -k https://api.ip.sb/geoip)
if [[ "$geoip" != "" ]]; then
echo "----------------------------------------"
echo "Info: "
echo "$geoip" | python -m json.tool
fi
fi

echo "========================================"
}

Expand Down Expand Up @@ -244,12 +251,15 @@ __auto_proxy() {
}

__zsh_proxy_update() {
__NOW_PATH=$(cd `dirname $0`; pwd)
cd "$HOME/.oh-my-zsh/custom/plugins/zsh-proxy"
__NOW_PATH=$(
cd "$(dirname "$0")" || exit
pwd
)
cd "$HOME/.oh-my-zsh/custom/plugins/zsh-proxy" || exit
git fetch --all
git reset --hard origin/master
source ~/.zshrc
cd ${__NOW_PATH}
source "$HOME/.zshrc"
cd "${__NOW_PATH}" || exit
}

# ==================================================
Expand Down

0 comments on commit f0f9d2b

Please sign in to comment.