From 2cc0bf3824323948cbf863153960e4af94e5cb74 Mon Sep 17 00:00:00 2001 From: Jeffrey Serio Date: Wed, 22 Jan 2025 12:28:58 -0600 Subject: [PATCH] Add quickinfo; refactor check-updates --- check-updates | 3 +-- quickinfo | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100755 quickinfo diff --git a/check-updates b/check-updates index bfaec08..5f56494 100755 --- a/check-updates +++ b/check-updates @@ -3,8 +3,7 @@ updates=() if [[ -f /etc/debian_version ]]; then - sudo apt update >/dev/null - updates+=("[ APT: $(sudo apt list --upgradable | tr -d '\n' | wc -l) ]") + updates+=("[ APT: $(sudo apt update 2>/dev/null | grep packages | cut -d '.' -f 1 | awk '{print $1}') ]") fi if [[ -f /etc/redhat-release ]]; then diff --git a/quickinfo b/quickinfo new file mode 100755 index 0000000..7ea323b --- /dev/null +++ b/quickinfo @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +if ! command -v gum >/dev/null; then + echo "Gum command not found" + exit 0 +fi + +function gumstyle() { + GUMSTYLE=$(gum style --foreground="#cba6f7" "$1") + echo "${GUMSTYLE} : ${2}" +} + +echo +source /etc/os-release +gum style --foreground="#f38ba8" "$(echo $PRETTY_NAME)" +echo +gumstyle "Kernel" "$(uname -sr)" +gumstyle "Uptime" "$(uptime -p)" +echo + +if [[ -f /etc/debian_version ]]; then + APT_PACKAGES=$(sudo apt update 2>/dev/null | grep packages | cut -d '.' -f 1 | awk '{print $1}') + gumstyle "APT updates" "$APT_PACKAGES" +fi + +if [[ -f /etc/redhat-release ]]; then + DNF_PACKAGES=$(sudo dnf check-update | wc -l) + gumstyle "DNF updates" "$DNF_PACKAGES" +fi + +if command -v flatpak >/dev/null; then + FLATPAK_PACKAGES=$(flatpak remote-ls --updates | wc -l) + gumstyle "Flatpak updates" "$FLATPAK_PACKAGES" +fi + +if [[ -d /home/linuxbrew/.linuxbrew ]]; then + BREW_PACKAGES=$(cat /home/jas/.homebrew_updates) + gumstyle "Homebrew updates" "$BREW_PACKAGES" +fi