-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcleanpack.sh
52 lines (50 loc) · 1.6 KB
/
cleanpack.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
while true; do
# Display the menu
echo "1. View and clean up orphaned packages"
echo "2. View and clean up unused packages"
echo "3. Quit"
read -p "Enter your choice: " choice
case $choice in
1) # Find and remove orphaned packages
orphaned_packages=$(pacman -Qtdq)
if [ -n "$orphaned_packages" ]; then
read -p "Do you want to see the orphaned packages in a table? (y/n) " choice
if [ "$choice" == "y" ]; then
pacman -Qi $orphaned_packages
fi
read -p "Do you want to remove these orphaned packages? (y/n) " choice
if [ "$choice" == "y" ]; then
pacman -Rns $orphaned_packages
fi
else
echo "No orphaned packages were found."
fi
;;
2) # Find unused packages
unused_packages=$(pacman -Qt)
if [ -n "$unused_packages" ]; then
read -p "Do you want to see the unused packages in a table? (y/n) " choice
if [ "$choice" == "y" ]; then
pacman -Qi $unused_packages
fi
# Prompt the user to select which unused packages to remove
read -p "Do you want to remove these unused packages? (y/n) " choice
if [ "$choice" == "y" ]; then
select package in $unused_packages; do
if [ -n "$package" ]; then
pacman -Rns $package
else
break
fi
done
fi
else
echo "No unused packages were found."
fi
;;
3) # Quit the script
break
;;
esac
done