Files
haikuports/app-shells/bash_completion/patches/bash_completion-2.14.0.patchset
OscarL f9b9df0071 bash_completion: update to version 2.14.0. (#11200)
* Fix completion of "pkgman install" for local files.
* Should avoid issues with future updates of the `bash_completion` package (#8157).
  Albeit it requires that users first manually remove the old
  `/boot/system/settings/etc/profile.d/bash_completion.sh` file previous to the
  installation of this package version (then should work OK in the future).
2024-10-11 17:26:29 +02:00

140 lines
3.7 KiB
Bash

From 7a33d288489e6b48ba54b6aa7ac33f4d7f713497 Mon Sep 17 00:00:00 2001
From: Oscar Lesta <oscar.lesta@gmail.com>
Date: Sat, 25 May 2024 01:47:20 -0300
Subject: Add pkgman and finddir support
Original patch by: Kostadin Damyanov <maxmight@gmail.com
Modified to allow auto-completion of `pkgman install` of local .hpkg files.
diff --git a/completions/Makefile.am b/completions/Makefile.am
index 219ea10..e6c2e4b 100644
--- a/completions/Makefile.am
+++ b/completions/Makefile.am
@@ -500,7 +500,9 @@ bashcomp_DATA = 2to3 \
_yum \
yum-arch \
zopfli \
- zopflipng
+ zopflipng \
+ pkgman \
+ finddir
EXTRA_DIST = $(bashcomp_DATA)
diff --git a/completions/finddir b/completions/finddir
new file mode 100644
index 0000000..cf7f6e4
--- /dev/null
+++ b/completions/finddir
@@ -0,0 +1,17 @@
+_finddir()
+{
+ local cur words
+ _init_completion || return
+
+ COMPREPLY=()
+ cur=${COMP_WORDS[COMP_CWORD]}
+
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '-l -v' -- "$cur" ) )
+ else
+ COMPREPLY=( $( compgen -W '$( finddir -l )' -- "$cur" ) )
+ fi
+
+ return 0
+} &&
+complete -F _finddir finddir
diff --git a/completions/pkgman b/completions/pkgman
new file mode 100644
index 0000000..f8a7628
--- /dev/null
+++ b/completions/pkgman
@@ -0,0 +1,52 @@
+_pkgman()
+{
+ local cur words
+ _init_completion || return
+
+ COMPREPLY=()
+ cur=${COMP_WORDS[COMP_CWORD]}
+
+ local special i
+ for (( i=0; i < ${#words[@]}-1; i++ )); do
+ if [[ ${words[i]} == @(install|uninstall) ]]; then
+ special=${words[i]}
+ fi
+ done
+
+ if [[ -n $special ]]; then
+ case $special in
+ install)
+ if [ -z "$cur" ]; then
+ return 0
+ fi
+
+ # First try with local packages.
+ local local_packages=$(compgen -f -X '!*.hpkg' "$cur")
+ if [ ! -z "$local_packages" ]; then
+ COMPREPLY=( $( compgen -W "$local_packages" -- "$cur" ) )
+ else
+ COMPREPLY=( $( compgen -W "$( pkgman search -a -D | awk 'NR>2 { print $2 }' )" -- "$cur" ) )
+ fi
+ return 0
+ ;;
+ uninstall)
+ COMPREPLY=( $( compgen -W "$( pkgman search -a -i | awk 'NR>2 { print $2 }' )" -- "$cur" ) )
+ return 0
+ ;;
+ *)
+ return 0
+ ;;
+ esac
+ fi
+
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '-h --help' -- "$cur" ) )
+ else
+ COMPREPLY=( $( compgen -W 'full-sync install search \
+ uninstall update add-repo drop-repo list-repos refresh \
+ resolve-dependencies' -- "$cur" ) )
+ fi
+
+ return 0
+} &&
+complete -F _pkgman pkgman
--
2.45.1
From 66495734b0a5ed9fab03d0955e7271d11d27e5a5 Mon Sep 17 00:00:00 2001
From: Oscar Lesta <oscar.lesta@gmail.com>
Date: Sat, 25 May 2024 01:52:08 -0300
Subject: Avoid using package version on paths for bash_completion.sh
This file ends up under $settingsDir/etc/profile.d, and it won't get
automatically updated (location is user writable) when installing
newer versions, breaking the auto-complete functionality.
See haikuports issue #8157.
diff --git a/bash_completion.sh.in b/bash_completion.sh.in
index a3bba6f..7c8d71e 100644
--- a/bash_completion.sh.in
+++ b/bash_completion.sh.in
@@ -7,9 +7,9 @@ if [ "x${BASH_VERSION-}" != x -a "x${PS1-}" != x -a "x${BASH_COMPLETION_VERSINFO
[ "${BASH_VERSINFO[0]}" -eq 4 -a "${BASH_VERSINFO[1]}" -ge 2 ]; then
[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion" ] &&
. "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion"
- if shopt -q progcomp && [ -r @datadir@/@PACKAGE@/bash_completion ]; then
+ if shopt -q progcomp && [ -r `finddir B_SYSTEM_DATA_DIRECTORY`/@PACKAGE@/bash_completion ]; then
# Source completion code.
- . @datadir@/@PACKAGE@/bash_completion
+ . `finddir B_SYSTEM_DATA_DIRECTORY`/@PACKAGE@/bash_completion
fi
fi
--
2.45.1