make script more reliable
This commit is contained in:
+6
-6
@@ -5,22 +5,22 @@
|
|||||||
# If no argument supplied, the host machine's ip will
|
# If no argument supplied, the host machine's ip will
|
||||||
# be used
|
# be used
|
||||||
# doc for api: https://ip-api.com/docs/api
|
# doc for api: https://ip-api.com/docs/api
|
||||||
ipinfo(){
|
function ipinfo(){
|
||||||
api_str=http://ip-api.com/json/$1?fields=query,country,regionName,city,district,zip,isp,org,reverse,mobile,proxy,hosting
|
local api_str="http://ip-api.com/json/$1?fields=query,country,regionName,city,district,zip,isp,org,reverse,mobile,proxy,hosting"
|
||||||
if ! hash python; then
|
if ! hash python; then
|
||||||
curl $api_str
|
curl "$api_str"
|
||||||
else
|
else
|
||||||
curl -s $api_str | python -m json.tool
|
curl -s "$api_str" | python -m json.tool
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# find file contain certain text string($2) in certain directory($1)
|
# find file contain certain text string($2) in certain directory($1)
|
||||||
fct(){
|
function fct(){
|
||||||
grep -rnw $1 -e $2
|
grep -rnw $1 -e $2
|
||||||
}
|
}
|
||||||
|
|
||||||
# online directory
|
# online directory
|
||||||
odict(){
|
function odict(){
|
||||||
curl dict://dict.org/d:"${1}"
|
curl dict://dict.org/d:"${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ cd \
|
|||||||
)
|
)
|
||||||
|
|
||||||
# in case above functions are broken
|
# in case above functions are broken
|
||||||
no_fzf(){
|
function no_fzf(){
|
||||||
for c in "${fzf_command_list_all[@]}"; do
|
for c in "${fzf_command_list_all[@]}"; do
|
||||||
unalias $c
|
unalias $c
|
||||||
done
|
done
|
||||||
@@ -35,7 +35,7 @@ no_fzf(){
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
dp(){
|
function dp(){
|
||||||
local debug=0
|
local debug=0
|
||||||
[ "$debug" = "1" ] && echo $1
|
[ "$debug" = "1" ] && echo $1
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ ret=''
|
|||||||
# 0: show all
|
# 0: show all
|
||||||
# 1: only show directories
|
# 1: only show directories
|
||||||
# 2: only show files
|
# 2: only show files
|
||||||
fzf_selector() {
|
function fzf_selector() {
|
||||||
ret=$1
|
ret=$1
|
||||||
if [ "$1" = "." ] || [ "$1" = ".." ] || \
|
if [ "$1" = "." ] || [ "$1" = ".." ] || \
|
||||||
[[ "$1" == -* ]] || [[ "$1" == */* ]]; then
|
[[ "$1" == -* ]] || [[ "$1" == */* ]]; then
|
||||||
@@ -130,7 +130,7 @@ fzf_selector() {
|
|||||||
# $1 command for fzf substuting(like ls)
|
# $1 command for fzf substuting(like ls)
|
||||||
# $2 original args pass to function
|
# $2 original args pass to function
|
||||||
# $3 command require file type (file: 0 |directory: 1)
|
# $3 command require file type (file: 0 |directory: 1)
|
||||||
fzf_command_execute() {
|
function fzf_command_execute() {
|
||||||
local args=($@)
|
local args=($@)
|
||||||
local len=${#args[@]}
|
local len=${#args[@]}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user