From 13a512276646acb5a847cbb79d87203d6047b4c7 Mon Sep 17 00:00:00 2001 From: Coby Powers Date: Sun, 20 Mar 2022 23:48:34 -0500 Subject: [PATCH] Add Update Alias --- sh/custom/aliases.sh | 11 +++++++++++ sh/custom/os.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 sh/custom/os.sh diff --git a/sh/custom/aliases.sh b/sh/custom/aliases.sh index 7a34b42..31118b5 100644 --- a/sh/custom/aliases.sh +++ b/sh/custom/aliases.sh @@ -19,6 +19,17 @@ alias rd='rm -rf' alias q='exit' +alias upd-arch='paru -S archlinux-keyring && paru' +alias upd-ubt='sudo apt update -y && sudo apt upgrade -y' + +if [[ "$OS" == "Arch Linux" ]]; then + alias upd='upd-arch' +elif [[ $OS == *"Ubuntu"* ]]; then + alias upd='upd-ubt' +else + alias upd='echo Failed to detect distribution' +fi + alias reload='source ~/.zshrc' alias aliases='cat $ALIASES' diff --git a/sh/custom/os.sh b/sh/custom/os.sh new file mode 100644 index 0000000..e392b89 --- /dev/null +++ b/sh/custom/os.sh @@ -0,0 +1,29 @@ +if [ -f /etc/os-release ]; then + # freedesktop.org and systemd + . /etc/os-release + OS=$NAME + VER=$VERSION_ID +elif type lsb_release >/dev/null 2>&1; then + # linuxbase.org + OS=$(lsb_release -si) + VER=$(lsb_release -sr) +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