nakadachi

PKGREMOVE

Aug 24th, 2025 (edited)
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.00 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. fzf_args=(
  4.   --multi
  5.   --preview 'echo "Commands: alt-p: toggle preview, alt-j/k: scroll, F11: maximize"; echo; yay -Qi {1}'
  6.   --preview-window 'down:65%:wrap'
  7.   --bind 'alt-p:toggle-preview'
  8.   --bind 'alt-d:preview-half-page-down,alt-u:preview-half-page-up'
  9.   --bind 'alt-k:preview-up,alt-j:preview-down'
  10.   --header 'Select packages to remove (Tab for multi-selection, Enter to confirm)'
  11. )
  12.  
  13. echo "Loading installed packages..."
  14. pkg_name=$(yay -Qqe | fzf "${fzf_args[@]}")
  15.  
  16. if [[ -n "$pkg_name" ]]; then
  17.   echo "Removing: $pkg_name"
  18.   echo "WARNING: This will remove the package and its unused dependencies"
  19.   read -p "Continue? (y/N): " confirm
  20.  
  21.   if [[ $confirm =~ ^[Yy]$ ]]; then
  22.     yay -Rns --noconfirm $pkg_name
  23.  
  24.     # Update file database
  25.     if command -v updatedb >/dev/null 2>&1; then
  26.       sudo updatedb
  27.     fi
  28.  
  29.     echo "Removal completed!"
  30.   else
  31.     echo "Operation cancelled."
  32.   fi
  33.  
  34.   read -p "Press Enter to continue..."
  35. else
  36.   echo "No packages selected."
  37. fi
  38.  
Advertisement
Add Comment
Please, Sign In to add comment