nirish

config files for niri window manager
Log | Files | Refs | README | LICENSE

pkg-aur-install (1782B)


      1 #!/usr/bin/env bash
      2 
      3 set -euo pipefail
      4 
      5 # Colors
      6 readonly RED='\e[31m'
      7 readonly GREEN='\e[32m'
      8 readonly YELLOW='\e[33m'
      9 readonly BLUE='\e[34m'
     10 readonly BOLD='\e[1m'
     11 readonly RESET='\e[0m'
     12 
     13 # Check required tools
     14 for tool in fzf yay; do
     15 	if ! command -v "$tool" >/dev/null 2>&1; then
     16 		echo -e "${RED}Error: $tool is not installed${RESET}"
     17 		[[ "$tool" == "yay" ]] && echo -e "${YELLOW}Install yay first: https://github.com/Jguer/yay${RESET}"
     18 		exit 1
     19 	fi
     20 done
     21 
     22 # FZF configuration
     23 fzf_args=(
     24 	--multi
     25 	--preview 'yay -Sii {1}'
     26 	--preview-label-pos='bottom'
     27 	--preview-window 'down:65%:wrap'
     28 	--color 'pointer:green,marker:green'
     29 	--header='Select AUR packages to install (TAB to select multiple, ENTER to confirm)'
     30 	--border
     31 )
     32 
     33 echo -e "${BLUE}${BOLD}Loading AUR package list...${RESET}\n"
     34 
     35 # Get package selections
     36 pkg_names=$(yay -Slqa | fzf "${fzf_args[@]}" || true)
     37 
     38 # Check if user selected anything
     39 if [[ -z "$pkg_names" ]]; then
     40 	echo -e "${YELLOW}No packages selected. Exiting.${RESET}"
     41 	exit 0
     42 fi
     43 
     44 # Show what will be installed
     45 echo -e "${BLUE}${BOLD}Selected AUR packages:${RESET}"
     46 echo "$pkg_names" | sed 's/^/  - /'
     47 echo
     48 
     49 # Convert to array for safe handling
     50 mapfile -t packages < <(echo "$pkg_names")
     51 
     52 # Install packages
     53 echo -e "${GREEN}${BOLD}Installing ${#packages[@]} AUR package(s)...${RESET}\n"
     54 
     55 if yay -S --noconfirm "${packages[@]}"; then
     56 	echo
     57 	echo -e "${GREEN}${BOLD}✓ Successfully installed ${#packages[@]} AUR package(s)${RESET}"
     58 else
     59 	echo
     60 	echo -e "${RED}${BOLD}✗ Installation failed or was incomplete${RESET}"
     61 fi
     62 
     63 echo
     64 
     65 # Keep window open
     66 if command -v gum >/dev/null 2>&1; then
     67 	gum spin --spinner "globe" --title "Done! Press any key to close..." -- bash -c 'read -n 1 -s'
     68 else
     69 	echo -e "${BLUE}Press any key to close...${RESET}"
     70 	read -n 1 -s
     71 fi