diff --git a/PRbL b/PRbL index 396430c..84e5100 160000 --- a/PRbL +++ b/PRbL @@ -1 +1 @@ -Subproject commit 396430c539486520f444fa3c6afb89e91c0dbbc8 +Subproject commit 84e5100e9b3857db076f9469ff1f59c4fea65871 diff --git a/extras/golang.install b/extras/golang.install index 4087645..1c24057 100755 --- a/extras/golang.install +++ b/extras/golang.install @@ -11,6 +11,11 @@ req_go_ver="1.19" golang_bashrc="# Golang system path setup export PATH=\$PATH:/usr/local/go/bin " +if [[ $OSTYPE == linux-gnu ]] ; then + sys_type="linux" +else + sys_type="$OSTYPE" +fi # Source PRbL Functions locally or retrieve from online if [ ! -z $prbl_functions ] ; then @@ -140,7 +145,7 @@ install(){ esac fi - local _golang_html=$(/usr/bin/curl -ks "https://go.dev/dl/" | grep $sys_arch | grep $req_go_ver | head -n 1) + local _golang_html=$(/usr/bin/curl -ks "https://go.dev/dl/" | grep $sys_type | grep $sys_arch | grep $req_go_ver | head -n 1) local golang_current=$(strip-html-tags "$_golang_html") #golang_current=$(echo "$golang_current" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') export tmp_dir=`mktemp -d /tmp/selfextract.XXXXXX` diff --git a/install.sh b/install.sh index 3420e47..77e4c05 100755 --- a/install.sh +++ b/install.sh @@ -66,6 +66,7 @@ packages=( vim lm-sensors curl + net-tools ) # OS distribution auto-detection @@ -187,14 +188,18 @@ install(){ # If script is run as root, run global install if [[ $runuser == root ]] ; then installdir="${globalinstalldir}" - prbl_bashrc="# Pyr0ball's Reductive Bash Library (PRbL) Functions library v$VERSION and greeting page setup -export prbl_functions=\"${installdir}/functions\"" + prbl_bashrc=" + # Pyr0ball's Reductive Bash Library (PRbL) Functions library v$VERSION and greeting page setup + export prbl_functions=\"${installdir}/functions\" + " globalinstall else # If user is non-root, run user-level install installdir="${userinstalldir}" - prbl_bashrc="# Pyr0ball's Reductive Bash Library (PRbL) Functions library v$VERSION and greeting page setup -export prbl_functions=\"${installdir}/functions\"" + prbl_bashrc=" + # Pyr0ball's Reductive Bash Library (PRbL) Functions library v$VERSION and greeting page setup + export prbl_functions=\"${installdir}/functions\" + " userinstall fi } diff --git a/lib/skel/.bashrc.d/01-aliases.bashrc b/lib/skel/.bashrc.d/01-aliases.bashrc new file mode 100644 index 0000000..864cbd6 --- /dev/null +++ b/lib/skel/.bashrc.d/01-aliases.bashrc @@ -0,0 +1,3 @@ +alias updateAll="sudo apt-get update ; sudo apt-get upgrade -y ; sudo apt-get dist-upgrade -y ; sudo apt-get autoremove -y" +alias superlocate='bash -xc '\''ag -g $0 --hidden'\'' 2>/dev/null' +alias dirSize="du -h -d 1" diff --git a/lib/skel/.bashrc.d/02-yt-dlp.bashrc b/lib/skel/.bashrc.d/02-yt-dlp.bashrc new file mode 100644 index 0000000..406bf1e --- /dev/null +++ b/lib/skel/.bashrc.d/02-yt-dlp.bashrc @@ -0,0 +1,5 @@ +alias updateall="sudo apt-get update ; sudo apt-get upgrade -y ; sudo apt-get dist-upgrade -y ; sudo apt-get autoremove -y" +alias superlocate='bash -xc '\''ag -g $0 --hidden'\'' 2>/dev/null' +alias grabVideo='yt-dlp --output "%(title)s.%(ext)s" --restrict-filenames --write-sub --sub-lang en --convert-subs srt --write-auto-sub' +alias grabAudio='yt-dlp --extract-audio --audio-format mp3 --output "%(title)s.%(ext)s" --restrict-filenames' +alias grabAlbum='yt-dlp --extract-audio --audio-format mp3 --output "%(title)s.%(ext)s" --restrict-filenames --split-chapters' diff --git a/lib/skel/.bashrc.d/11-quickinfo.bashrc b/lib/skel/.bashrc.d/11-quickinfo.bashrc index d19f5ee..5b80ac3 100755 --- a/lib/skel/.bashrc.d/11-quickinfo.bashrc +++ b/lib/skel/.bashrc.d/11-quickinfo.bashrc @@ -9,48 +9,9 @@ # Written by Alan "pyr0ball" Weinstock # ############################################################### -quickinfo_version=2.1.0 +quickinfo_version=2.1.1 prbl_functons_req_ver=1.6.0 -# Uses a wide variety of methods to check which distro this is run on -# TODO: Add alternative handling for other environments -if type lsb_release >/dev/null 2>&1; then - # linuxbase.org - OS=$(lsb_release -si) - VER=$(lsb_release -sr) -elif [ -f /etc/debian_version ]; then - # Older Debian/Ubuntu/etc. - OS=Debian - VER=$(cat /etc/debian_version) -elif [ -f /etc/os-release ]; then - # freedesktop.org and systemd - . /etc/os-release - OS=$NAME - VER=$VERSION_ID -elif [ -f /etc/lsb-release ]; then - # For some versions of Debian/Ubuntu without lsb_release command - . /etc/lsb-release - OS=$DISTRIB_ID - VER=$DISTRIB_RELEASE -elif [ -f /etc/debian_version ]; then - # Older Debian/Ubuntu/etc. - OS=Debian - VER=$(cat /etc/debian_version) -elif [ -f /etc/SuSe-release ]; then - # Older SuSE/etc. - ... -elif [ -f /etc/redhat-release ]; then - # Older Red Hat, CentOS, etc. - ... -else - # Fall back to uname, e.g. "Linux ", also works for BSD, etc. - OS=$(uname -s) - VER=$(uname -r) -fi - - -# If running on login as a bashrc, the above variables will not give this script's data -# Failover hardcoded settings location for now if running from login environment # TODO: Need to re-test after v2.2.x ### TODO: This implementation is still broken. context for location breaks during login @@ -62,7 +23,10 @@ fi # if ! [ -f "$HOME/.bashrc.d/11-quickinfo.settings"] ; then # settingsfile="$HOME/.bashrc.d/11-quickinfo.settings" # else - # default quickinfo bashrc Preferences + + ######################################## + # Default quickinfo bashrc Preferences # + ######################################## # Disable run on non-interactive sessions (set true to disable) interactive_only=false @@ -77,25 +41,76 @@ fi filtered_adapters="lo" # Disks - # separate disk types with '\|' ex. "sd\|nvme" - allowed_disk_prefixes="sd\|md\|mapper\|nvme\|mmcblk\|root" - disallowed_disks="boot" + + allowed_disk_prefixes=( + sd + md + mapper + nvme + mmcblk + root + ) + + disallowed_disk_prefixes=( + boot + ) + + ####################################################### + # Do not change these unless you know what you're doing + # convert array to grep string + for prefix in "${allowed_disk_prefixes[@]}" ; do + allowed_disk_prefixes_string+="\\|$prefix" + done + # Remove the leading '\|' from the grep string + allowed_disk_prefixes_string="${allowed_disk_prefixes_string:2}" + + # Manual regex string + # To use, uncomment and separate disk types with '\|' ex. "sd\|nvme" + # or use any other grep-compatible filtering desired + #allowed_disk_prefixes_string="sd\|md\|mapper\|nvme\|mmcblk\|root" + + + for prefix in "${disallowed_disk_prefixes[@]}" ; do + disallowed_disk_prefixes_string+="\\|$prefix" + done + disallowed_disk_prefixes_string="${allowed_disk_prefixes_string:2}" # fi # fi # source $settingsfile # source PRbL functions +# Source PRbL Functions locally or retrieve from online if [ ! -z $prbl_functions ] ; then - source $prbl_functions + source $prbl_functions else - # Failover if global variable is not defined. Checks for 'functions' in same location - echo -e "PRbL functions not defined. Check ~/.bashrc" - if [ -f "${BASH_SOURCE[0]%/*}/functions" ] ; then - source ${BASH_SOURCE[0]%/*}/functions - else - echo -e "local functions file also missing. Some visual elements will be missing" - fi + if [ -f ${rundir}/functions ] ; then + source ${rundir}/functions + else + # Iterate through get commands and fall back on next if unavailable + if command -v curl >/dev/null 2>&1; then + source <(curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions') + elif command -v wget >/dev/null 2>&1; then + source <(wget -qO- 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions') + elif command -v fetch >/dev/null 2>&1; then + source <(fetch -qo- 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions') + else + echo "Error: curl, wget, and fetch commands are not available. Please install one to retrieve PRbL functions." + exit 1 + fi + fi fi + +# if [ ! -z $prbl_functions ] ; then +# source $prbl_functions +# else +# # Failover if global variable is not defined. Checks for 'functions' in same location +# echo -e "PRbL functions not defined. Check ~/.bashrc" +# if [ -f "${BASH_SOURCE[0]%/*}/functions" ] ; then +# source $rundir/functions +# else +# echo -e "local functions file also missing. Some visual elements will be missing" +# fi +# fi # Locate and import settings (shares same name with script apart from file extension) scriptname="${BASH_SOURCE[0]##*/}" rundir="${BASH_SOURCE[0]%/*}" @@ -179,6 +194,7 @@ fi # TODO: optimize this to run after time delay using timestamp in settings set_spinner spinner19 #spin "eval $(wan_ip=$(wget -qO- http://ipecho.net/plain \| xargs echo ))" +#spin read -r wan_ip < <(wget -qO- http://ipecho.net/plain \| xargs echo) wan_ip=$(wget -qO- http://ipecho.net/plain \| xargs echo ) #spin read -r wan_ip < <(wget -qO- https://ident.me/) @@ -279,7 +295,7 @@ declare -a macs=() declare -a ifups=() for device in $(ls /sys/class/net/ | grep -v "$filtered_adapters") ; do adapters+=($device) - _ip=$(ip -f inet -o addr show $device | cut -d\ -f 7 | cut -d/ -f 1 | head -n 1) + _ip=$(ip -o -f inet addr show $device | awk '{print $4}' | cut -d/ -f 1 | head -n 1) if valid-ip $_ip ; then ips+=("$_ip") ifups+=("up") @@ -297,7 +313,7 @@ declare -a logicals=() declare -a mounts=() declare -a usages=() declare -a freespaces=() -diskinfo=$(/bin/df -h | grep "$allowed_disk_prefixes" | grep -v "$disallowed_disks") +diskinfo=$(/bin/df -h | grep "$allowed_disk_prefixes_string" | grep -v "$disallowed_disk_prefixes_string") logicals=($(cut -d ' ' -f1 <<< "${diskinfo}")) mounts=($(awk '{print $6}' <<< "${diskinfo}")) usages=($(awk '{print $5}' <<< "${diskinfo}")) @@ -326,7 +342,7 @@ boxline "" boxline "${bld}${unl}Location:${dfl} ${grn}${unl}$location${dfl}" boxline "" # Echo out network arrays -for ((i=0; i<"${#adapters[@]}"; i++ )); do +for ((i=0; i<"${#adapters[@]}"; i++ )) ; do if [[ $show_disconnected != true ]] ; then if [[ ${ifups[$i]} == up ]] ; then boxline " ${adapters[$i]}: ${cyn}${ips[$i]}${dfl} | ${blu}${macs[$i]}${dfl}" @@ -346,7 +362,7 @@ boxline " CPU Temp: ${lbl}${cputemp}${dfl} | Utilization: ${lrd}${cpu_util}%${d boxline " Memory used/total: ${mem_usage}" boxline " ${unl}Disk Info:${dfl}" boxline "${unl}$(printf '\t|%-4s\t%-4s\t%-4s\t%-4s\n' Usage Free Mount Volumes)${dfl}" -for ((i=0; i<"${#logicals[@]}"; i++ )); do +for ((i=0; i<"${#logicals[@]}" ; i++ )) ; do boxline " $(printf '|%-4s\t%-4s\t%-4s\t%-4s\n' ${usages[$i]} ${freespaces[$i]} ${mounts[$i]} ${logicals[$i]})" done boxline ""