pkgsrc/shells/bash-completion/patches/patch-bash__completion
2017-03-14 14:51:28 +00:00

51 lines
1.4 KiB
Text

$NetBSD: patch-bash__completion,v 1.2 2017/03/14 14:51:28 jperkin Exp $
Added pkgsrc and pkg_install completions
Pull in upstream fix for bug 1289597.
--- bash_completion.orig 2013-04-05 10:55:51.000000000 +0000
+++ bash_completion
@@ -707,7 +707,7 @@ _init_completion()
fi
done
- [[ $cword -eq 0 ]] && return 1
+ [[ $cword -le 0 ]] && return 1
prev=${words[cword-1]}
[[ ${split-} ]] && _split_longopt && split=true
@@ -1365,6 +1365,34 @@ _terms()
extract patch configure build install reinstall deinstall clean
clean-depends kernel buildworld' make
+# a little help for NetBSD pkgsrc users
+[[ $OSTYPE = *netbsd* ]] && complete -W 'index search fetch fetch-list \
+ extract patch configure build install reinstall \
+ deinstall package clean clean-depends' make
+
+
+[[ $OSTYPE = *netbsd* ]] && {
+# NetBSD package management tool completion
+#
+_pkg_delete()
+{
+ local cur pkgdir prev
+
+ pkgdir=${PKG_DBDIR:-/var/db/pkg}/
+ cur=`_get_cword`
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ [ "$prev" = "-o" -o "$prev" = "-p" -o "$prev" = "-W" ] && return 0
+
+ COMPREPLY=( $( compgen -d $pkgdir$cur ) )
+ COMPREPLY=( ${COMPREPLY[@]#$pkgdir} )
+
+ return 0
+}
+complete -F _pkg_delete $dirnames pkg_delete pkg_info
+have pkg_deinstall && complete -F _pkg_delete $dirnames pkg_deinstall
+}
+
# This function provides simple user@host completion
#
_user_at_host()