From 580b1d856a6cdd5ed4eebeb52460e982f0dc5f6a Mon Sep 17 00:00:00 2001 From: Donaldttt Date: Sat, 2 Jul 2022 17:08:55 -0400 Subject: [PATCH] improve shell compatability --- bash_tools.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bash_tools.sh b/bash_tools.sh index 0ac4875..8fef881 100644 --- a/bash_tools.sh +++ b/bash_tools.sh @@ -4,9 +4,16 @@ # If no argument supplied, the host machine's ip will # be used # doc for api: https://ip-api.com/docs/api -DOTFILE_DIR=$(dirname ${BASH_SOURCE[0]})/ -source $DOTFILE_DIR/bash_tools/helper.sh +if [ ! -z "$ZSH_NAME" ]; then + SHELL_NAME=zsh + DOTFILE_DIR=${0:a:h}/ +else + SHELL_NAME=bash + DOTFILE_DIR=$(dirname ${BASH_SOURCE[0]})/ +fi + +source "$DOTFILE_DIR/bash_tools/helper.sh" function ipinfo(){ local api_str="http://ip-api.com/json/$1?fields=query,country,regionName,city,district,zip,isp,org,reverse,mobile,proxy,hosting"