78 lines
1.5 KiB
Bash
78 lines
1.5 KiB
Bash
#!/bin/bash
|
|
|
|
|
|
if [[ ! $(command -v arch) ]]; then
|
|
function arch() {
|
|
uname -m
|
|
}
|
|
fi
|
|
|
|
function function_list {
|
|
if [ $1 ]; then
|
|
# will list functions in passed file
|
|
local STR
|
|
local func
|
|
declare -a FUNCS
|
|
STR=$(grep '() {\|(){\|function' $1)
|
|
readarray -t LIST <<<"$STR"
|
|
for func in "${LIST[@]}"
|
|
do
|
|
if [[ ! $func =~ ^# ]]; then
|
|
func=${func#function }
|
|
func=${func%()?( ){}
|
|
[[ ! $func =~ ^_ ]] && FUNCS+=($func)
|
|
fi
|
|
done
|
|
echo "${FUNCS[@]}"
|
|
else
|
|
# will list all sourced/declared functions available
|
|
echo
|
|
echo -e "\033[1;4;32m""Functions:""\033[0;34m"
|
|
declare -F | grep -v "declare -f\s_" | awk {'print $3'}
|
|
echo
|
|
echo -e "\033[0m"
|
|
fi
|
|
}
|
|
|
|
function alias_list() {
|
|
echo
|
|
echo -e "\033[1;4;32m""Aliases:""\033[0;34m"
|
|
alias | awk {'print $2'} | awk -F= {'print $1'}
|
|
echo
|
|
echo -e "\033[0m"
|
|
}
|
|
|
|
get_shopt () {
|
|
echo $([ "$(shopt -p $1 | grep '\-s')" ] && echo on || echo off)
|
|
}
|
|
|
|
# edit files
|
|
# echo set the system editor using EDITOR environment variable
|
|
edit() { ${EDITOR:-nano} $@; }
|
|
gedit() { ${GEDITOR:-xed} $@; }
|
|
|
|
|
|
unlocku () ( faillock --user $1 --reset )
|
|
|
|
rsynchg() { rsync --help | grep "\-$1"; }
|
|
|
|
|
|
gip () {
|
|
if which jqx &> /dev/null; then
|
|
curl -s "https://dns.google/resolve?name=$1" | jq -r '.Answer[] | .data'
|
|
return 0
|
|
else
|
|
echo install jq to use this function
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
gpip () {
|
|
curl https://ipv4.nsupdate.info/myip
|
|
}
|
|
|
|
|
|
dip () {
|
|
/bin/drill $1 | grep -A1 'ANSWER SECTION' | grep -v "ANSWER SECTION" | rev | cut -f1 | rev
|
|
}
|