From 1be77958d282aed1f7b272dfd38551eeedfb02ed Mon Sep 17 00:00:00 2001 From: dataprolet Date: Thu, 9 May 2024 14:56:41 +0000 Subject: [PATCH] Initial commit. --- Scripts/remove.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Scripts/remove.sh diff --git a/Scripts/remove.sh b/Scripts/remove.sh new file mode 100644 index 0000000..982621e --- /dev/null +++ b/Scripts/remove.sh @@ -0,0 +1,40 @@ +# Script to easily remove packages without having to spell the whole package-name. + +# Create the following alias to make removing packages even easier: +# alias remove="sh /path/to/remove.sh" + +# Now you can remove packages by using the following command: +# remove $packagename + +#!/bin/bash + +# Query installed packages for the search term and create a variable from it +pkgs=( $(pacman -Qq | grep $1) ) + +# Make it an array +declare -a pkgs + +# If array contains only one entry, remove immediately +if [ ${#pkgs[@]} -eq 1 ]; then + # If installed, use yay to uninstall the selected package and all of it's dependecies and configuration files + if type yay >/dev/null 2>&1; then + yay -Rns $pkgs + else + # Else use pacman to uninstall the selected package and all of it's dependecies and configuration files + sudo pacman -Rns $pkgs + fi +else + # Else select the right package from the array + select pkg in ${pkgs[@]} + do + break + done + + # If installed, use yay to uninstall the selected package and all of it's dependecies and configuration files + if type yay >/dev/null 2>&1; then + yay -Rns $pkgs + else + # Else use pacman to uninstall the selected package and all of it's dependecies and configuration files + sudo pacman -Rns $pkgs + fi +fi \ No newline at end of file