From f039f0a08ba6add879392948e9211fb684238246 Mon Sep 17 00:00:00 2001 From: manuel Date: Sun, 4 Aug 2024 21:53:55 +0300 Subject: [PATCH] [eos-packagelist] faster bash completion --- eos-packagelist/PKGBUILD | 8 +++-- .../eos-packagelist.bash-completion | 31 +++++++++---------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/eos-packagelist/PKGBUILD b/eos-packagelist/PKGBUILD index f0b1abbc..67aeb6df 100644 --- a/eos-packagelist/PKGBUILD +++ b/eos-packagelist/PKGBUILD @@ -2,7 +2,7 @@ # Contributor : Sravan Pannala pkgname=eos-packagelist -pkgver=2.3 +pkgver=2.3.1 pkgrel=1 pkgdesc="An application to gather and optionally install package lists from the EndeavourOS installer" arch=('any') @@ -14,9 +14,13 @@ source=( eos-packagelist.bash-completion ) sha256sums=('0f421de391d125c437ec86af584db60fd1f71a09c8b26506d1b60620ac429270' - '73a68cde33cd2cbbba0ebf7c39f10dc8993e73f3d40debd9e4899d4e84a1ca07') + '097c09ef22e981ec9dc6e1a8b6e5172c2558b0c52fe4dbd9949a55b448f8bdfb') package() { + local profiles=eos-packagelist.profiles + eos-packagelist --list | sort -u > $profiles + install -Dm0755 "$srcdir/eos-packagelist" "$pkgdir/usr/bin/eos-packagelist" install -Dm0644 eos-packagelist.bash-completion "$pkgdir/usr/share/bash-completion/completions/eos-packagelist" + install -Dm0644 $profiles "$pkgdir/etc/$profiles" } diff --git a/eos-packagelist/eos-packagelist.bash-completion b/eos-packagelist/eos-packagelist.bash-completion index 4867df0f..4f7bdc26 100644 --- a/eos-packagelist/eos-packagelist.bash-completion +++ b/eos-packagelist/eos-packagelist.bash-completion @@ -1,19 +1,19 @@ # bash completion for eos-packagelist -*- shell-script -*- _eos-packagelist_complete() { - local IFS=$'\n' # handles spaces in names! + local IFS="$newline" # handles spaces in names! COMPREPLY=($(compgen -W "$1" -- "$cur")) [[ $COMPREPLY == *= ]] && compopt -o nospace compopt -o nosort - # quote the selectable items but not flags - local item ix + # quote the profiles but not flags + local profile ix local -r count=${#COMPREPLY[@]} for ((ix=0; ix < count; ix++)) ; do - item="${COMPREPLY[$ix]}" - case "$item" in + profile="${COMPREPLY[$ix]}" + case "$profile" in -*) ;; - *) COMPREPLY[$ix]="'$item'" ;; + *) [ "${profile// /}" != "$profile" ] && COMPREPLY[$ix]="'$profile'" ;; esac done } @@ -23,32 +23,29 @@ _eos-packagelist_() local cur prev #words cword split _init_completion -s || return + local -r newline=$'\n' + # eos-packagelist options local options=( - --help -h --list --arch --install - ) - - # architectures supported by eos-packagelist - local architectures=( - x86_64 aarch64 armv7h + --help -h --list --install ) + # eos-packagelist profiles + local -r profiles=$(< /etc/eos-packagelist.profiles) # Handle options that need sub-options. case "$prev" in - --arch) - _eos-packagelist_complete "$(printf "%s\n" "${architectures[@]}")" - ;; *) # Handle all top-level parameters. + local -r options2=$(printf "%s\n" "${options[@]}") case "$cur" in -*) # Any option. - _eos-packagelist_complete "$(printf "%s\n" "${options[@]}")" + _eos-packagelist_complete "$options2" ;; *) # Non-option parameters. - _eos-packagelist_complete "$(printf "%s\n" "${options[@]}"; eos-packagelist --list | sort)" + _eos-packagelist_complete "$options2$newline$profiles" ;; esac ;;