2020-11-03 12:07:49 -08:00
|
|
|
#!/bin/bash
|
|
|
|
# 00 will get loaded first
|
|
|
|
|
2023-01-18 16:43:21 -08:00
|
|
|
##
|
2023-02-09 08:34:18 -08:00
|
|
|
module_load systemd
|
2021-02-11 18:29:28 -08:00
|
|
|
|
|
|
|
user_reload() {
|
|
|
|
save=$PWD
|
|
|
|
exec su -l $USER
|
|
|
|
cd $save
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function function_list {
|
2020-11-06 14:24:10 -08:00
|
|
|
if [ $1 ]; then
|
2020-11-13 10:25:04 -08:00
|
|
|
# will list functions in passed file
|
2020-11-06 14:24:10 -08:00
|
|
|
local STR
|
|
|
|
local func
|
|
|
|
declare -a FUNCS
|
|
|
|
STR=$(grep '() {\|(){\|function' $1)
|
|
|
|
readarray -t LIST <<<"$STR"
|
|
|
|
for func in "${LIST[@]}"
|
|
|
|
do
|
|
|
|
if [[ ! $func =~ ^# ]]; then
|
2020-11-13 10:25:04 -08:00
|
|
|
func=${func#function }
|
2020-11-06 14:24:10 -08:00
|
|
|
func=${func%()?( ){}
|
|
|
|
[[ ! $func =~ ^_ ]] && FUNCS+=($func)
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo "${FUNCS[@]}"
|
|
|
|
else
|
2020-11-27 09:59:16 -08:00
|
|
|
# will list all sourced/declared functions available
|
2020-11-03 12:07:49 -08:00
|
|
|
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"
|
2020-11-06 14:24:10 -08:00
|
|
|
fi
|
2020-11-03 12:07:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
|
|
|
rsynchc() { rsync --help | grep "\-$1"; }
|
|
|
|
alias rsynch="rsynchc"
|
|
|
|
|
2020-11-06 14:24:10 -08:00
|
|
|
get_shopt () {
|
|
|
|
echo $([ "$(shopt -p $1 | grep '\-s')" ] && echo on || echo off)
|
|
|
|
}
|
|
|
|
|
2020-11-03 12:07:49 -08:00
|
|
|
change-ext() {
|
2020-11-06 14:24:10 -08:00
|
|
|
local depth
|
|
|
|
local d
|
|
|
|
d=${3:-0}
|
|
|
|
let d+=1
|
|
|
|
[ $d -lt 1 ] && depth="" || depth=" -maxdepth $d "
|
|
|
|
find . $depth -name '*.'$1 -exec rename -n 's/\.'$1'/.'$2'/' \{} \;
|
|
|
|
read -p "do REALLY want to change the extensions? " -n 1 -r
|
|
|
|
echo
|
|
|
|
[[ ! $REPLY =~ ^[Yy]$ ]] && return 1
|
|
|
|
find . $depth -name '*.'$1 -exec rename 's/\.'$1'/.'$2'/' \{} \;
|
2020-11-03 12:07:49 -08:00
|
|
|
}
|
2020-11-06 14:24:10 -08:00
|
|
|
|
2020-11-03 12:07:49 -08:00
|
|
|
alias chext=change-ext
|
|
|
|
|
|
|
|
# find in any file
|
|
|
|
fif() {
|
|
|
|
grep -rnswl $1 -e $2 | more
|
|
|
|
}
|
|
|
|
|
|
|
|
# edit files
|
|
|
|
# set the system editor using EDITOR environment variable
|
|
|
|
editor() { ${EDITOR} $1; }
|
2021-10-28 12:05:56 -07:00
|
|
|
|
|
|
|
add-repo-key () {
|
|
|
|
gpg --keyserver keyserver.ubuntu.com --recv-key $1
|
|
|
|
gpg -a --export $1 | sudo apt-key add -
|
2022-10-24 18:13:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
osinfo () {
|
|
|
|
echo kernel: $(uname -r)
|
|
|
|
echo machine: $(arch)
|
|
|
|
cat /etc/os-release
|
|
|
|
cat /etc/upstream-release/lsb-release
|
|
|
|
}
|
|
|
|
|
2023-01-21 08:18:40 -08:00
|
|
|
|
2022-10-24 18:13:58 -07:00
|
|
|
alias ssudo="ssudo "
|