changed bash_aliases to the better

This commit is contained in:
pika 2025-03-08 21:05:13 +01:00
parent 1551aa9dc2
commit 118bc0d1ed

View file

@ -46,83 +46,64 @@ check_root() {
check_root
getPackager() {
pkg="apt dnf pacman zypper apk"
for pkgmgr in $pkg; do
if command_exists "$pkgmgr"; then
PACKAGER="$pkgmgr"
fi
done
# Load OS release information
[ -f /etc/os-release ] && . /etc/os-release || return 1
case "$PACKAGER" in
apt)
DISTRO="${ID}:${ID_LIKE}"
case "$DISTRO" in
*debian*)
if command_exists nala; then
search="nala search"
install="nala install --assume-yes"
refresh="nala update"
upgrade="nala upgrade --full"
remove="nala purge"
alias update="$_sudo $refresh && $_sudo $upgrade"
alias install="$_sudo $refresh && $_sudo $install"
alias remove="$_sudo $remove"
alias search="$search"
elif command_exists apt; then
search="apt-cache search"
install="apt-get install --yes"
refresh="apt-get update"
upgrade="apt-get upgrade"
remove="apt-get purge"
alias update="$_sudo $refresh && $_sudo $upgrade"
alias install="$_sudo $refresh && $_sudo $install"
alias remove="$_sudo $remove"
alias search="$search"
alias search="nala search"
alias install="$_sudo nala install --assume-yes"
alias update="$_sudo nala update && $_sudo nala upgrade --full"
alias remove="$_sudo nala purge"
else
echo_error "APT ERROR"
alias search="apt-cache search"
alias install="$_sudo apt-get install --yes"
alias update="$_sudo apt-get update && $_sudo apt-get upgrade"
alias remove="$_sudo apt-get purge"
fi
alias unbreak="$_sudo dpkg --configure -a"
;;
dnf)
if command_exists dnf; then
alias install="dnf install --yes"
alias update="dnf update"
alias remove="dnf remove"
alias search="dnf search"
else
echo_error "DNF ERROR"
fi
;;
pacman)
if command_exists yay; then
alias install="yay -S --noconfirm"
alias update="yay -Syu"
alias remove="yay -R"
alias search="yay -Ss"
elif command_exists paru; then
*arch*)
if command_exists paru; then
alias search="paru -Ss"
alias install="paru -S --noconfirm"
alias update="paru -Syu"
alias remove="paru -R"
alias search="paru -Ss"
elif command_exists pacman; then
elif command_exists yay; then
alias search="yay -Ss"
alias install="yay -S --noconfirm"
alias update="yay -Syu"
alias remove="yay -R"
else
alias search="$_sudo pacman -Ss"
alias install="$_sudo pacman -S --noconfirm"
alias update="$_sudo pacman -Syu"
alias remove="$_sudo pacman -R"
alias search="$_sudo pacman -Ss"
else
echo_error "PACMAN ERROR"
fi
;;
zypper)
alias install="$_sudo zypper install"
alias update="$_sudo zypper dup"
alias remove="$_sudo zypper remove"
alias search="$_sudo zypper search"
*rhel* | *fedora*)
alias search="dnf search"
alias install="$_sudo dnf install -y --skip-missing"
alias update="$_sudo dnf update -y"
alias remove="$_sudo dnf remove -y"
;;
apk)
install="apk add"
update="apk update"
upgrade="apk upgrade"
remove="apk del"
alias install="$_sudo $install"
alias update="$_sudo $update && $_sudo $upgrade"
alias remove="$_sudo $remove"
*suse*)
alias search="zypper search"
alias install="$_sudo zypper install --no-confirm"
alias update="$_sudo zypper update"
alias remove="$_sudo zypper remove"
;;
*alpine*)
alias install="$_sudo apk add"
alias update="$_sudo apk update && $_sudo apk upgrade"
alias remove="$_sudo apk del"
;;
*)
echo "Unsupported distro: $ID"
return 1
;;
esac
}
@ -308,16 +289,16 @@ _alias_() {
# Function to determine which Neovim command to use
choose_nvim() {
if [ -n "$DISPLAY" ] || [ -n "$WAYLAND_DISPLAY" ]; then
if [ -n "$TMUX" ]; then
# If inside an active tmux session, use nvim
echo "command nvim"
return
elif [ -n "$DISPLAY" ] || [ -n "$WAYLAND_DISPLAY" ]; then
# If in a graphical environment, use Neovide
if command_exists neovide; then
echo "neovide --fork"
return
fi
elif [ -n "$TMUX" ]; then
# If inside an active tmux session, use nvim
echo "command nvim"
return
fi
# Default to nvim
echo "command nvim"