💻 Small shell functions to make my life easier
Check my external IP
function myip {
case "$1" in
4 | 6)
echo
tput bold; echo -e '\e[0;93mIPv'$1; tput sgr0
curl -s "http://v$1.ipv6-test.com/api/myip.php"
;;
*)
echo
tput bold; echo -e '\e[0;93mIPv4'; tput sgr0
curl -4 -s "http://ipv6-test.com/api/myip.php"
echo -e "\n"
tput bold; echo -e '\e[0;93mIPv6'; tput sgr0
curl -6 -s "http://ipv6-test.com/api/myip.php"
;;
esac
echo
}
Check the current weather
CurrentWeather ()
{
curl 'wttr.in/City?m&lang=pt&format=%l:+%C+%c+\nFeels:%f+\nTemp:%t\n'
}
System update and cleanup
function sysupdate {
local native() {
tput bold;
echo "\n\e[0;93mUpdating native packages..."
tput sgr0;
paru -Syyuv;
}
local fltpk() {
tput bold;
echo "\n\e[0;93mUpdating flatpaks..."
tput sgr0;
flatpak update;
}
local cleanup() {
array=($HOME/.cargo $HOME/.cache/go-build $HOME/.npm $HOME/.cache/paru $HOME/.cache/winetricks $HOME/.cache/wine $HOME/.cache/spotify $HOME/.cache/pnmp $HOME/.cache/pip $HOME/go)
for ((i = 1; i <= $#array; i++)) {
if [ -d $array[i] ]; then
tput bold;
echo -e "\n\e[0;93mDeleting $array[i]...";
tput sgr0;
rm -rfv -- $array[i];
fi
}
tput bold;
echo -e "\n\e[0;93mDeleting native package cache...";
tput sgr0;
paru -Sccc
}
case "$1" in
-p)
native;;
-f)
fltpk;;
-c)
cleanup;;
-a)
native; fltpk; cleanup;;
-h | *)
echo -e "-p\t Update native packages\n-f\t Update Flatpaks\n-c\t Cleanup after system update. Also includes stuff from ~/.cache\n-h\t Show help";;
esac
}
#Shell #Functions #CLI #Terminal