Improve setup and update scripts pt.2
This commit is contained in:
@ -5,7 +5,8 @@
|
||||
" \ \ / / \ \ \ \ \ \ \ \ \ \\ \\ \ \____
|
||||
" \ \__/ / \ \__\ \__\ \ \__\ \__\\ _\\ \_______\
|
||||
" \|__|/ \|__|\|__| \|__|\|__|\|__|\|_______|
|
||||
" by Coby Powers (inspired by https://www.freecodecamp.org/news/vimrc-configuration-guide-customize-your-vim-editor/)
|
||||
" by Coby Powers
|
||||
" (inspired by https://www.freecodecamp.org/news/vimrc-configuration-guide-customize-your-vim-editor/)
|
||||
|
||||
" Remove compatibility with vi
|
||||
set nocompatible
|
||||
|
@ -18,28 +18,16 @@ alias md='mkdir -p'
|
||||
alias rd='rm -rf'
|
||||
|
||||
alias q='exit'
|
||||
|
||||
alias c='clear'
|
||||
|
||||
alias journal='journalctl -xe'
|
||||
alias journal-err='journalctl -p 3 -b'
|
||||
|
||||
alias fstab='sudo vim /etc/fstab'
|
||||
alias fstab='_ vim /etc/fstab'
|
||||
|
||||
alias rcron='sudo crontab -e'
|
||||
alias cron='crontab -e'
|
||||
|
||||
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. The script needs to be able to determine the distribution to know which package manager to use'
|
||||
fi
|
||||
|
||||
alias reload='source ~/.zshrc'
|
||||
|
||||
alias aliases='cat $ALIASES'
|
||||
|
@ -1,29 +0,0 @@
|
||||
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 <version>", also works for BSD, etc.
|
||||
OS=$(uname -s)
|
||||
VER=$(uname -r)
|
||||
fi
|
@ -1,22 +0,0 @@
|
||||
declare -A osInfo;
|
||||
osInfo[/etc/redhat-release]=yum
|
||||
osInfo[/etc/arch-release]=pacman
|
||||
osInfo[/etc/gentoo-release]=emerge
|
||||
osInfo[/etc/SuSE-release]=zypp
|
||||
osInfo[/etc/debian_version]=apt-get
|
||||
osInfo[/etc/alpine-release]=apk
|
||||
|
||||
for key val in "${(@kv)osInfo}"; do
|
||||
if [[ -f $key ]];then
|
||||
PACKAGE_MANAGER=$val
|
||||
fi
|
||||
done
|
||||
|
||||
install_package() {
|
||||
if [ "$PACKAGE_MANAGER" == "yum" ]; then yum install -y $1
|
||||
elif [ "$PACKAGE_MANAGER" == "pacman" ]; then pacman -S --noconfirm $1
|
||||
elif [ "$PACKAGE_MANAGER" == "emerge" ]; then emerge $1
|
||||
elif [ "$PACKAGE_MANAGER" == "zypp" ]; then zypper install $1
|
||||
elif [ "$PACKAGE_MANAGER" == "apt-get" ]; then apt-get install -y $1
|
||||
elif [ "$PACKAGE_MANAGER" == "apk" ]; then apk add $1; fi
|
||||
}
|
Reference in New Issue
Block a user