Skip to content

Commit

Permalink
Release 2.8.5
Browse files Browse the repository at this point in the history
fix(zshbop): Set $ZSHBOP_UPDATE_GIT as to not presist through reloads.
fix(init): Fix $MACHINE_OS and add $MACHINE_OS2 added init_home_bin
fix(glint): Fixed glint OS detection and install
style(git): Added function infront of functions for better searching :)
fix(software): Glint checking added return 1 so that _cexists works properly
fix(zshbop): Fixed branch command when not in zshbop directory
style(init): Ensure init_check_vm shows errors so they're more prominent.
improvement(init): Improved init_check_vm
improvement(init): Improved init_check_vm message to install qemu-guest-agent
improvement(zshbop): Addd faults to zshbop reports to show just faults
enhance(zshbop): Create category faults for zshbop report
style(glint): Print categories before running gc
style(init): Making init text smaller and easier to distinguish
style(init): Changed style to be more compact
  • Loading branch information
jordantrizz authored and root committed May 24, 2023
1 parent ac1db4f commit 2b4a50b
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 130 deletions.
16 changes: 13 additions & 3 deletions cmds/cmds-git.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,20 @@ typeset -gA help_git

# - gc
help_git[gc]='Git commit + push'
gc () {
function gc () {
_cexists glint
if [[ $? == "0" ]]; then
_loading "Committing using glint"
echo "build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
docs: Documentation only changes
feat: A new feature
fix: A bug fix
perf: A code change that improves performance
refactor: A code change that neither fixes a bug nor adds a feature
style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
test: Adding missing tests or correcting existing tests
"
glint commit
git push
else
Expand All @@ -29,7 +39,7 @@ gc () {

# - gbdc
help_git[gbdc]='git branch diff on commits'
gbdc () {
function gbdc () {
if [[ ! -n $1 ]] || [[ ! -n $2 ]]; then
echo "Usage: gbdc <branch> <branch>"
else
Expand All @@ -39,7 +49,7 @@ gbdc () {

# -- git-config
help_git[git-config]='Configure git name and email'
git-config () {
function git-config () {
vared -p "Name? " -c GIT_NAME
vared -p "Email? " -c GIT_EMAIL
git config --global user.email $GIT_EMAIL
Expand Down
6 changes: 3 additions & 3 deletions cmds/cmds-linux.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ fi
help_linux[broot]='Get an overview of a directory, even a big one'
_cexists broot
if [[ $? == "1" ]]; then
broot () {
function broot () {
check_broot
}
check_broot () {
_error "broot not installed"
function check_broot () {
_error "broot not installed" 0
}
fi

Expand Down
28 changes: 16 additions & 12 deletions cmds/cmds-software.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ b2_download () {
chmod u+x $HOME/bin/b2-linux
if [[ $? -ge 1 ]]; then
_error "Download failed."
else
else
_success "b2-linux downloaded to $HOME/bin, run the b2 command"
alias b2=b2-linux
fi
Expand All @@ -223,8 +223,8 @@ b2_download () {
alias b2=b2-darwin
fi
fi
fi
}
fi
}

# -- powershell
help_software[powershell]="Powershell for Linux"
Expand Down Expand Up @@ -324,7 +324,7 @@ function software_jiq () {

# -- plik-conf
help_software[plik-conf]='Print out .plikrc'
function plik-conf () {
function plik-conf () {
if [[ ! -f $HOME/.plikrc ]]; then
_error "No $HOME/.plikrc exists"
return 1
Expand Down Expand Up @@ -353,35 +353,39 @@ function bat() {
}

# -- glint
help_software[change]="Install glint - https://github.com/brigand/glint"
help_software[glint]="Install glint - https://github.com/brigand/glint"
if [[ $MACHINE_OS == "linux" ]]; then
_debug "Check for gblint-linux under $MACHINE_OS"
_cexists glint-linux
if [[ $? == "0" ]]; then
function glint () { glint-linux $* }
function glint () { glint-linux $* }
function software_glint { _success "Glint installed" }
else
function glint () { _error "Glint not installed, type software glint to install" }
function software_glint {
function glint () { _error "Glint not installed, type software glint to install"; return 1; }
function software_glint {
_loading "Installing glint"
curl -L -o $HOME/bin/glint-linux https://github.com/brigand/glint/releases/download/v6.3.4/glint-linux
chmod u+x $HOME/bin/glint-macos
chmod u+x $HOME/bin/glint-linux
_loading3 "Reload shell"
}
fi
elif [[ $MACHINE_OS == "mac" ]]; then
_debug "Check for gblint-linux under $MACHINE_OS"
_cexists glint-macos
if [[ $? == "0" ]]; then
function glint () { glint-macos $* }
function glint () { glint-macos $* }
function software_glint { _success "Glint installed" }
else
function glint () { _error "Glint not installed, type software glint to install" }
else
function glint () { _error "Glint not installed, type software glint to install"; return 1; }
function software_glint {
_loading "Installing glint"
curl -L -o $HOME/bin/glint-macos https://github.com/brigand/glint/releases/download/v6.3.4/glint-macos
chmod u+x $HOME/bin/glint-macos
_loading3 "Reload shell"
}
fi
else
_debug "Couldn't detect OS for glint"
fi

# -- change
Expand Down
56 changes: 26 additions & 30 deletions cmds/cmds-system.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,21 @@ help_files[system]='System commands'
# - Init help array
typeset -gA help_system

# -- cpu
help_system[cpu]='Get CPU cores and threads.'
cpu () {
eval "lscpu | grep -E '^Thread|^Core|^Socket|^CPU\(|Model name|CPU MHz:|Hypervisor vendor:'"
}

# -- highcpu
help_system[highcpu]='Get processes with high CPU usage.'
alias highcpu="ps aux | sort -nrk 3,3 | head -n 5"

# -- mem
help_system[mem]='Get memory information'
alias mem="free -m"

# -- disk
help_system[disk]='Get disk information'
alias disk="lsblk"

# -- sysinfo
help_system[sysinfo]='Get system information'
sysinfo () {
_loading "CPU"
cpu
_loading "Memory"
mem
_loading "Disk"
disk
_loading "Short Format"
}

# -- sysinfo
help_system[yabs]='Run yabs'
alias yabs="yabs.sh"

help_system[system-specs]='Print system specs'
function system-specs () {
# -- cpu
help_system[cpu]='CPU Information'
function cpu () {
# -- FreeBSD
if [[ $MACHINE_OS == "freebsd" ]]; then
mhz=$(sysctl -n hw.cpufrequency | awk '{print $1/1000000}')
Expand All @@ -59,26 +38,43 @@ function system-specs () {
_error "Please install the bc command"
else
if (( $(echo "$CPU_MHZ < 3" | bc -l) )); then
CPU_CHECK=$(_error "CPU Mhz = $CPU_MHZ and is below 3Ghz")
CPU_CHECK=$(_error "CPU Mhz = $CPU_MHZ and is below 3Ghz" 0 )
elif (( $(echo "$CPU_MHZ < 3.5" | bc -l) )); then
CPU_CHECK=$(_warning "CPU Mhz = $CPU_MHZ and is between 3Ghz and 3.5Ghz")
CPU_CHECK=$(_warning "CPU Mhz = $CPU_MHZ and is between 3Ghz and 3.5Ghz" 0)
else
CPU_CHECK=$(_success "CPU Mhz = $CPU_MHZ and is 3.5Ghz or above")
CPU_CHECK="CPU Mhz = $CPU_MHZ and is 3.5Ghz or above"
fi
fi

CPU_SOCKET=$(lscpu | awk '/^Socket/{print $2}')
CPU_CORES=$(lscpu | awk '/^Core\(s\) per socket/{print $4}')
CPU_THREADS=$(lscpu | awk '/^CPU\(s\)/{print $2}')
CPU_MODEL=$(lscpu | awk '/Model name:/ { $1=""; print $0 }' | sed 's/^ name: *//')
echo " - $CPU_MODEL - ${CPU_SOCKET}S/${CPU_CORES}C/${CPU_THREADS}T @ ${CPU_MHZ}"
echo " - $CPU_CHECK"
echo " - Memory: $(free -g | awk '/^Mem:/{print $2}')GB"
echo "CPU: $CPU_MODEL - ${CPU_SOCKET}S/${CPU_CORES}C/${CPU_THREADS}T @ ${CPU_MHZ} || $CPU_CHECK"
else
_error "system-specs not implemented for $MACHINE_OS"
fi
}

# -- mem
help_system[mem]='Get memory information'
function mem () {
memory_info=$(free -m | awk 'NR==2 {printf "%s MB used, %s MB free, %s MB cached", $3, $4, $6}')
echo "Memory: $memory_info"
}

# -- sysinfo
help_system[sysinfo]='Get system information'
sysinfo () {
_loading "CPU"
cpu
_loading "Memory"
mem
_loading "Disk"
disk
_loading "Short Format"
}

help_system[count-files-directories]='Count files and directories'
function count-files-directories () {
local target_dir="$1"
Expand Down
6 changes: 5 additions & 1 deletion cmds/os-common.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ os-binary "exa"
os-binary "glow"

# -- sysfetch
sysfetch () {
function sysfetch () {
DEFAULT_SYSFETCH="neofetch"
export FASTFETCH_CONFIG="--structure Title:OS:Host:Kernel:Uptime:Packages:CPU:GPU:Memory:Disk:Shell:Terminal:TerminalFont:Locale --logo none"
_debug "Checking if fastfetch is installed"
Expand All @@ -33,6 +33,10 @@ sysfetch () {
fi
}

function sysfetch-short () {
eval "${FASTFETCH_CMD} --structure Title:OS:Host:Kernel:Uptime --logo none"
}

# -- tran - https://github.com/abdfnx/tran/releases
alias tran="tran_linux_amd64"

Expand Down
61 changes: 30 additions & 31 deletions cmds/os-linux.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -26,40 +26,39 @@ alias tran="tran_linux_amd64"
# -- interfaces
help_linux[interfaces]="List interfaces ip, mac and link"
interfaces_linux () {
# Get a list of all network interfaces
interfaces=($(ip -o link show | awk '{print $2}' | tr -d ':'))
local OUTPUT=""
local INTERFACES=()
local INTERFACES_OUTPUT=""

# Loop through each interface
OUTPUT=$(_banner_grey "Interface IP Mac Speed")
for interface in $interfaces; do
_debug "Processing interface: $interface"
if [[ $interface == *NONE* ]] && { interface=$(echo $interface | sed 's/@NONE//g'); _debug "Found @NONE in \$interface, removing @NONE"; }

# Get MAC address
mac=$(ip -o link show $interface | awk '{print $17}')
# -- Check if ifconfig commmand exists
_cexists ifconfig
if [[ $? -ge "1" ]]; then
_error "ifconfig command not found, required, run zshbop install-env"
return 1
fi

# Get link speed
speed=$(ethtool $interface 2>>/dev/null | grep 'Speed: ' | awk '{print $2}')
[[ -z $speed ]] && speed="N/A"
# -- Get a list of all network interfaces
INTERFACES=("${(f)$(ip -o link show | awk '{print $2}' | sed 's/://')}")

# Get IP address
ip=$(ip -o addr show $interface | awk '{print $3","$4}')
if [[ "${ip%%\n*}" != "${ip}" ]]; then
_debug " -- Found multiple IP addresses for $interface"
while read -r ip; do
_debug "Interface: $interface IP: $ip MAC: $mac Speed: $speed"
OUTPUT+="\n$interface $ip $mac $speed"
done <<< "${ip}"
elif [[ -z $ip ]]; then
_debug " -- No IP address found for $interface"
OUTPUT+="\n$interface N/A $mac $speed"
else
# Print interface information
_debug "Interface: $interface IP: $ip MAC: $mac Speed: $speed"
OUTPUT+="\n$interface $ip $mac $speed"
fi
done
echo -e "$OUTPUT" | column -t
# -- Loop through each interface
for INTERFACE in $INTERFACES; do

# -- Get MAC address
INTERFACE_MAC=$(ifconfig $INTERFACE | awk '/ether/{print $2}')

# -- Get link speed
INTERFACE_SPEED=$(ethtool $INTERFACE 2> /dev/null | awk '/Speed:/ {print $2}')
[[ -z $INTERFACE_SPEED ]] && INTERFACE_SPEED="N/A"

# Get IP address
INTERFACE_IP=$(ifconfig $INTERFACE | awk '/inet /{print $2}')

# -- Print interface information
_debug "$INTERFACE:$INTERFACE_IP - $INTERFACE_MAC $INTERFACE_SPEED"
INTERFACES_OUTPUT+="$INTERFACE:$INTERFACE_IP - $INTERFACE_MAC $INTERFACE_SPEED || "
done

echo "$INTERFACES_OUTPUT"
}

# -- check_diskspace_linux
Expand Down
Loading

0 comments on commit 2b4a50b

Please sign in to comment.