From 660b5649a1316e63482e53617f1a1d984db0e26d Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Sat, 12 Aug 2023 17:22:53 -0700 Subject: [PATCH 1/8] changed ifconfig to ip a for wider compatibility --- lib/skel/.bashrc.d/11-quickinfo.bashrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/skel/.bashrc.d/11-quickinfo.bashrc b/lib/skel/.bashrc.d/11-quickinfo.bashrc index e158853..398999e 100755 --- a/lib/skel/.bashrc.d/11-quickinfo.bashrc +++ b/lib/skel/.bashrc.d/11-quickinfo.bashrc @@ -277,7 +277,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") @@ -324,7 +324,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}" @@ -344,7 +344,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 "" From f349ab08541af9f6274068b4b3822ea52a39e83f Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Thu, 28 Sep 2023 22:47:41 -0700 Subject: [PATCH 2/8] fixed functions source and issues when curl is missing --- lib/skel/.bashrc.d/11-quickinfo.bashrc | 117 ++++++++++++++----------- 1 file changed, 66 insertions(+), 51 deletions(-) diff --git a/lib/skel/.bashrc.d/11-quickinfo.bashrc b/lib/skel/.bashrc.d/11-quickinfo.bashrc index 398999e..0274c63 100755 --- a/lib/skel/.bashrc.d/11-quickinfo.bashrc +++ b/lib/skel/.bashrc.d/11-quickinfo.bashrc @@ -12,45 +12,6 @@ quickinfo_version=2.1.0 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 $rundir/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]%/*}" From 9ed70241e90d7c0bc0c36378e3f8f3992d66568d Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Thu, 28 Sep 2023 23:08:02 -0700 Subject: [PATCH 3/8] fixed grep string using wrong var --- lib/skel/.bashrc.d/11-quickinfo.bashrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/skel/.bashrc.d/11-quickinfo.bashrc b/lib/skel/.bashrc.d/11-quickinfo.bashrc index 0274c63..8834e2a 100755 --- a/lib/skel/.bashrc.d/11-quickinfo.bashrc +++ b/lib/skel/.bashrc.d/11-quickinfo.bashrc @@ -309,8 +309,8 @@ done declare -a logicals=() declare -a mounts=() declare -a usages=() -declare -a freespaces=() -diskinfo=$(/bin/df -h | grep "$allowed_disk_prefixes" | grep -v "$disallowed_disks") +declare -a freespaces=() $allo +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}")) From f6a86d2cc81cb17ac60a80eb6ccf2805b058a4d4 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Thu, 28 Sep 2023 23:11:00 -0700 Subject: [PATCH 4/8] iterated minor version --- lib/skel/.bashrc.d/11-quickinfo.bashrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/skel/.bashrc.d/11-quickinfo.bashrc b/lib/skel/.bashrc.d/11-quickinfo.bashrc index 8834e2a..9b15345 100755 --- a/lib/skel/.bashrc.d/11-quickinfo.bashrc +++ b/lib/skel/.bashrc.d/11-quickinfo.bashrc @@ -9,7 +9,7 @@ # Written by Alan "pyr0ball" Weinstock # ############################################################### -quickinfo_version=2.1.0 +quickinfo_version=2.1.1 prbl_functons_req_ver=1.6.0 # TODO: Need to re-test after v2.2.x @@ -309,7 +309,7 @@ done declare -a logicals=() declare -a mounts=() declare -a usages=() -declare -a freespaces=() $allo +declare -a freespaces=() 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}")) From b9fb14bc7c63700ec1b42bcdaa5b879c2fcf6b6a Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Sat, 30 Sep 2023 23:32:11 -0700 Subject: [PATCH 5/8] modified installer echo out --- install.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 278454d..0a5c050 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 } @@ -393,8 +398,8 @@ userinstall(){ # Check for existing bashrc config, append if missing if [[ $(cat ${HOME}/.bashrc | grep -c 'bashrc.d') == 0 ]] ; then take-backup $HOME/.bashrc - run echo -e "$bashrc_append" >> $HOME/.bashrc && boxborder "bashc.d installed..." || warn "Malformed append on ${lbl}${HOME}/.bashrc${dfl}. Check this file for errors" - run echo -e "$prbl_bashrc" >> $HOME/.bashrc.d/00-prbl.bashrc && boxborder "bashc.d/00-prbl installed..." || warn "Malformed append on ${lbl}${HOME}/.bashrc.d/00-prbl.bashrc${dfl}. Check this file for errors" + echo -e "$bashrc_append" >> $HOME/.bashrc && boxborder "bashc.d installed..." || warn "Malformed append on ${lbl}${HOME}/.bashrc${dfl}. Check this file for errors" + echo -e "$prbl_bashrc" >> $HOME/.bashrc.d/00-prbl.bashrc && boxborder "bashc.d/00-prbl installed..." || warn "Malformed append on ${lbl}${HOME}/.bashrc.d/00-prbl.bashrc${dfl}. Check this file for errors" fi From 806c593037c8a6e7cc015b7d004ee7de73241669 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Mon, 2 Oct 2023 22:56:14 -0700 Subject: [PATCH 6/8] fixed go link parser --- extras/golang.install | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extras/golang.install b/extras/golang.install index 74f362b..4a8f66d 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` From 9b308fdaf8bdbe8635370748b2e8ca9ed1deddbf Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Sun, 14 Apr 2024 10:13:23 -0700 Subject: [PATCH 7/8] fixed broken wan check --- lib/skel/.bashrc.d/11-quickinfo.bashrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/skel/.bashrc.d/11-quickinfo.bashrc b/lib/skel/.bashrc.d/11-quickinfo.bashrc index 9b15345..bd9672c 100755 --- a/lib/skel/.bashrc.d/11-quickinfo.bashrc +++ b/lib/skel/.bashrc.d/11-quickinfo.bashrc @@ -193,7 +193,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- https://ident.me/) +spin read -r wan_ip < <(wget -qO- http://ipecho.net/plain \| xargs echo) # Checks memory usage mem_usage=$(free -m | grep Mem | awk '{print $3"M/"$2"M"}') From 2b570faf2b66cce6ae1aa6f22504345e66060582 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Sun, 22 Sep 2024 13:59:56 -0700 Subject: [PATCH 8/8] updated to PRbL 1.7.3, added new aliases --- PRbL | 2 +- lib/skel/.bashrc.d/01-aliases.bashrc | 3 +++ lib/skel/.bashrc.d/02-yt-dlp.bashrc | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 lib/skel/.bashrc.d/01-aliases.bashrc create mode 100644 lib/skel/.bashrc.d/02-yt-dlp.bashrc 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/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'