summaryrefslogtreecommitdiffstats
path: root/extra/source/bash-completion
diff options
context:
space:
mode:
author Patrick J Volkerding <volkerdi@slackware.com>2011-04-25 13:37:00 +0000
committer Eric Hameleers <alien@slackware.com>2018-05-31 22:45:18 +0200
commit75a4a592e5ccda30715f93563d741b83e0dcf39e (patch)
tree502f745607e77a2c4386ad38d818ddcafe81489c /extra/source/bash-completion
parentb76270bf9e6dd375e495fec92140a79a79415d27 (diff)
downloadcurrent-75a4a592e5ccda30715f93563d741b83e0dcf39e.tar.gz
current-75a4a592e5ccda30715f93563d741b83e0dcf39e.tar.xz
Slackware 13.37slackware-13.37
Mon Apr 25 13:37:00 UTC 2011 Slackware 13.37 x86_64 stable is released! Thanks to everyone who pitched in on this release: the Slackware team, the folks producing upstream code, and linuxquestions.org for providing a great forum for collaboration and testing. The ISOs are off to be replicated, a 6 CD-ROM 32-bit set and a dual-sided 32-bit/64-bit x86/x86_64 DVD. Please consider supporting the Slackware project by picking up a copy from store.slackware.com. We're taking pre-orders now, and offer a discount if you sign up for a subscription. As always, thanks to the Slackware community for testing, suggestions, and feedback. :-) Have fun!
Diffstat (limited to 'extra/source/bash-completion')
-rw-r--r--extra/source/bash-completion/bash-completion-1.1-pkgtools_tgxz.diff12
-rwxr-xr-xextra/source/bash-completion/bash-completion.SlackBuild31
-rw-r--r--extra/source/bash-completion/bash_completion.sh12
-rw-r--r--extra/source/bash-completion/contrib/pkgtools127
-rw-r--r--extra/source/bash-completion/contrib/rpm2tgz14
-rw-r--r--extra/source/bash-completion/contrib/sbopkg76
-rw-r--r--extra/source/bash-completion/contrib/slackpkg95
-rw-r--r--extra/source/bash-completion/contrib/slapt136
-rw-r--r--extra/source/bash-completion/fixup-sh-script-completions.diff22
9 files changed, 495 insertions, 30 deletions
diff --git a/extra/source/bash-completion/bash-completion-1.1-pkgtools_tgxz.diff b/extra/source/bash-completion/bash-completion-1.1-pkgtools_tgxz.diff
deleted file mode 100644
index 803f59918..000000000
--- a/extra/source/bash-completion/bash-completion-1.1-pkgtools_tgxz.diff
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -Nur bash-completion-1.1.orig//contrib/pkgtools bash-completion-1.1//contrib/pkgtools
---- bash-completion-1.1.orig//contrib/pkgtools 2009-10-09 07:49:31.000000000 -0500
-+++ bash-completion-1.1//contrib/pkgtools 2010-03-06 21:56:50.343715164 -0600
-@@ -11,7 +11,7 @@
- COMPREPLY=( $( (cd /var/log/packages; compgen -f -- "$cur") ) )
- } &&
- complete -F _removepkg $filenames removepkg &&
-- complete $dirnames -f -X '!*.tgz' installpkg upgradepkg explodepkg
-+ complete $dirnames -f -X '!*.t[gx]z' installpkg upgradepkg explodepkg
-
- # Local variables:
- # mode: shell-script
diff --git a/extra/source/bash-completion/bash-completion.SlackBuild b/extra/source/bash-completion/bash-completion.SlackBuild
index 3fb915c02..d2e59446b 100755
--- a/extra/source/bash-completion/bash-completion.SlackBuild
+++ b/extra/source/bash-completion/bash-completion.SlackBuild
@@ -1,6 +1,6 @@
#!/bin/sh
-# Copyright 2009, 2010 Patrick J. Volkerding, Sebeka, Minnesota, USA
+# Copyright 2009, 2010, 2011 Patrick J. Volkerding, Sebeka, Minnesota, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
@@ -22,9 +22,9 @@
# Slackware build script for bash-completion
-VERSION=1.1
+VERSION=1.3
ARCH=noarch
-BUILD=${BUILD:-3}
+BUILD=${BUILD:-4}
CWD=$(pwd)
TMP=${TMP:-/tmp}
@@ -43,26 +43,35 @@ find . \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
-exec chmod 644 {} \;
-# Add support for txz packages instead of only tgz
-zcat $CWD/bash-completion-1.1-pkgtools_tgxz.diff.gz | patch -p1 || exit 1
+# Fixup sh completion for us
+zcat $CWD/fixup-sh-script-completions.diff.gz | patch -p1 --verbose || exit 1
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--mandir=/usr/man \
--infodir=/usr/info \
- --docdir=/usr/doc/bash_completion-$VERSION
+ --docdir=/usr/doc/bash-completion-$VERSION
make || exit 1
make install DESTDIR=$PKG || exit 1
-
+
mkdir -p $PKG/etc/profile.d
zcat $CWD/bash_completion.sh.gz > $PKG/etc/profile.d/bash_completion.sh
chmod 0755 $PKG/etc/profile.d/bash_completion.sh
+# Sorry, but these contrib scripts have been causing a lot of problems.
+# If these are merged with upstream (and hopefully debugged) then we
+# will have them, but adding them at this level is IMHO a mistake.
+## https://github.com/GArik/bash-completion
+## GArik has a 'slackware' branch with quite a few enhancements
+#for i in pkgtools rpm2tgz sbopkg slackpkg slapt ; do
+# cat $CWD/contrib/$i > $PKG/etc/bash_completion.d/$i ;
+#done
+
mkdir -p $PKG/usr/doc/bash-completion-$VERSION
cp -a \
- AUTHORS COPYING README TODO \
+ AUTHORS COPYING* README* TODO \
$PKG/usr/doc/bash-completion-$VERSION
# If there's a ChangeLog, installing at least part of the recent history
@@ -73,6 +82,12 @@ if [ -r CHANGES ]; then
touch -r CHANGES $DOCSDIR/CHANGES
fi
+# Contrib scripts can go in with the documentation:
+cp -a $CWD/contrib $PKG/usr/doc/bash-completion-$VERSION
+chown -R root:root $PKG/usr/doc/bash-completion-$VERSION
+chmod 755 $PKG/usr/doc/bash-completion-$VERSION/contrib
+chmod 644 $PKG/usr/doc/bash-completion-$VERSION/contrib/*
+
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
diff --git a/extra/source/bash-completion/bash_completion.sh b/extra/source/bash-completion/bash_completion.sh
index 4f2cdf824..cb2adb673 100644
--- a/extra/source/bash-completion/bash_completion.sh
+++ b/extra/source/bash-completion/bash_completion.sh
@@ -1,11 +1,3 @@
-bash=${BASH_VERSION%.*}; bmajor=${bash%.*}; bminor=${bash#*.}
-if [ "$PS1" ] && [ $bmajor -eq 2 ] && [ $bminor '>' 04 ] \
- && [ -f /etc/bash_completion ]; then # interactive shell
- # Source completion code
- . /etc/bash_completion
-elif [ "$PS1" ] && [ $bmajor -ge 3 ] \
- && [ -f /etc/bash_completion ]; then # interactive shell
- # Source completion code
- . /etc/bash_completion
+if [ "$(basename $SHELL)" = "bash" -a -f /etc/bash_completion ]; then
+ . /etc/bash_completion
fi
-unset bash bmajor bminor
diff --git a/extra/source/bash-completion/contrib/pkgtools b/extra/source/bash-completion/contrib/pkgtools
new file mode 100644
index 000000000..2b438efca
--- /dev/null
+++ b/extra/source/bash-completion/contrib/pkgtools
@@ -0,0 +1,127 @@
+# bash completion for Slackware Linux pkgtools
+
+[ -f /etc/slackware-version ] &&
+{
+
+have pkgtool &&
+_pkgtool()
+{
+ COMPREPLY=()
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '--sets --ignore-tagfiles --tagfile \
+ --source-mounted --source_dir --target_dir --source_device' \
+ -- "$cur" ) )
+ return 0
+ fi
+
+ local prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ case $prev in
+ --source_dir|--target_dir)
+ _filedir -d
+ return 0
+ ;;
+ --sets)
+ # argument required but no completions available
+ return 0
+ ;;
+ --source_device)
+ COMPREPLY=( $( compgen -f -d -- "${cur:-/dev/}" ) )
+ return 0
+ ;;
+ --tagfile)
+ _filedir
+ return 0
+ ;;
+ esac
+} &&
+complete -F _pkgtool pkgtool
+
+have removepkg &&
+_removepkg()
+{
+ COMPREPLY=()
+ local cur=`_get_cword`
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '-copy -keep -preserve -warn' \
+ -- "$cur" ) )
+ return 0
+ fi
+
+ COMPREPLY=( $( cd /var/log/packages; compgen -f -- "$cur" ) )
+} &&
+complete -F _removepkg removepkg
+
+have upgradepkg &&
+_upgradepkg()
+{
+ COMPREPLY=()
+ local cur=`_get_cword`
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '--dry-run --install-new --reinstall \
+ --verbose' -- "$cur") )
+ return 0
+ fi
+
+ _filedir "t[bglx]z"
+} && complete -F _upgradepkg upgradepkg
+
+have installpkg &&
+_installpkg()
+{
+ COMPREPLY=()
+ local cur=`_get_cword`
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '--warn --md5sum --root --infobox --terse \
+ --menu --ask --priority --tagfile' -- "$cur") )
+ return 0
+ fi
+
+ local prev=`_get_pword`
+
+ case $prev in
+ --root)
+ _filedir -d
+ return 0
+ ;;
+ --priority)
+ COMPREPLY=( $( compgen -W 'ADD REC OPT SKP' -- "$cur" ) )
+ return 0
+ ;;
+ --tagfile)
+ _filedir
+ return 0
+ ;;
+ esac
+
+ _filedir "t[bglx]z"
+} && complete -F _installpkg installpkg
+
+have makepkg &&
+_makepkg()
+{
+ COMPREPLY=()
+ local cur=`_get_cword`
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '-l --linkadd -p --prepend \
+ -c --chown' -- "$cur") )
+ return 0
+ fi
+
+ local prev=`_get_pword`
+
+ case $prev in
+ -l|--linkadd|-c|--chown)
+ COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
+ return 0
+ ;;
+ esac
+
+ _filedir
+} && complete -F _makepkg makepkg
+
+have explodepkg &&
+complete -o plusdirs -f -X '!*.t[bglx]z' explodepkg
+
+}
diff --git a/extra/source/bash-completion/contrib/rpm2tgz b/extra/source/bash-completion/contrib/rpm2tgz
new file mode 100644
index 000000000..23c70ac9f
--- /dev/null
+++ b/extra/source/bash-completion/contrib/rpm2tgz
@@ -0,0 +1,14 @@
+# Slackware rpm2tgz completion.
+
+have rpm2tgz &&
+_rpm2tgz()
+{
+ COMPREPLY=()
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '-s -S -n -r -d -c' -- "$cur" ) )
+ return 0
+ fi
+
+ COMPREPLY=( $(compgen -f -X "!*.rpm" -- "$cur") )
+} && complete -F _rpm2tgz -o plusdirs rpm2tgz rpm2txz rpm2targz
diff --git a/extra/source/bash-completion/contrib/sbopkg b/extra/source/bash-completion/contrib/sbopkg
new file mode 100644
index 000000000..698fdf18d
--- /dev/null
+++ b/extra/source/bash-completion/contrib/sbopkg
@@ -0,0 +1,76 @@
+# bash completion for sbopkg tool
+
+have sbopkg &&
+_sbopkg()
+{
+ COMPREPLY=()
+ local cur prev
+ _get_comp_words_by_ref cur prev
+
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '-b -c -d -e -f -g -h -i -k -l \
+ -o -P -p -q -R -r -s -u -V -v' -- "$cur" ) )
+ return 0
+ fi
+
+ case $prev in
+ -e)
+ COMPREPLY=( $( compgen -W 'ask continue stop' -- "$cur" ) )
+ return 0
+ ;;
+ -f)
+ _filedir
+ return 0
+ ;;
+ -d)
+ _filedir -d
+ return 0
+ ;;
+ -V)
+ COMPREPLY=( $( compgen -W "? \
+ $(sbopkg -V ? 2>&1 | cut -s -f1)" -- "$cur" ) )
+ return 0
+ ;;
+ -i|-b)
+ ;;
+ *)
+ return 0
+ ;;
+ esac
+
+ local config="/etc/sbopkg/sbopkg.conf"
+ local words
+ _get_comp_words_by_ref words
+
+ for (( i=${#words[@]}-1; i>0; i-- )); do
+ if [[ "${words[i]}" == -f ]]; then
+ config="${words[i+1]}"
+ break
+ fi
+ done
+
+ if [ ! -r "$config" ]; then
+ return 0
+ fi
+
+ . $config
+
+ for (( i=1; i<${#words[@]}; i++ )); do
+ case "${words[i]}" in
+ -V)
+ REPO_NAME="${words[i+1]%%/*}"
+ REPO_BRANCH="${words[i+1]#*/}"
+ ;;
+ -d)
+ REPO_ROOT="${words[i+1]}"
+ ;;
+ esac
+ done
+
+ if [ ! -r "$REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT" ]; then
+ return 0
+ fi
+ COMPREPLY=( $( sed -ne "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p}"\
+ $REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT )
+ $( cd $QUEUEDIR; compgen -f -X "!*.sqf" -- "$cur" ) )
+} && complete -F _sbopkg sbopkg
diff --git a/extra/source/bash-completion/contrib/slackpkg b/extra/source/bash-completion/contrib/slackpkg
new file mode 100644
index 000000000..139e7edd7
--- /dev/null
+++ b/extra/source/bash-completion/contrib/slackpkg
@@ -0,0 +1,95 @@
+# bash completion for slackpkg tool
+
+have slackpkg &&
+_slackpkg()
+{
+ COMPREPLY=()
+ local cur
+ _get_comp_words_by_ref cur
+
+ # based on `grep '\-.*\=.*)' /usr/sbin/slackpkg | cut -f1 -d\)`
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '-delall=on -delall=off \
+ -checkmd5=on -checkmd5=off \
+ -checkgpg=on -checkgpg=off \
+ -checksize=on -checksize=off \
+ -postinst=on -postinst=off \
+ -onoff=on -onoff=off \
+ -download_all=on -download_all=off \
+ -dialog=on -dialog=off \
+ -dialog_maxargs= \
+ -batch=on -batch=off \
+ -only_new_dotnew=on -only_new_dotnew=off \
+ -use_includes=on -use_includes=off \
+ -spinning=on -spinning=off \
+ -default_answer=yes -default_answer=no \
+ -mirror=' -- "$cur" ) )
+ return 0
+ fi
+
+ local confdir="/etc/slackpkg"
+ local config="$confdir/slackpkg.conf"
+
+ if [ ! -r "$config" ]; then
+ return 0
+ fi
+ . "$config"
+
+ local action words
+ _get_comp_words_by_ref -n "=" words
+
+ for (( i=1; i<${#words[@]}; i++ )); do
+ if [[ "${words[i]}" != -* ]]; then
+ action="${words[i]}"
+ break
+ fi
+ done
+
+ case $action in
+ generate-template|search|file-search)
+ # argument required but no completions available
+ return 0
+ ;;
+ install-template|remove-template)
+ if [ -e "$confdir/templates" ]; then
+ COMPREPLY=( $( cd "$confdir/templates"; \
+ compgen -f -X "!*.template" -- "$cur" ) )
+ COMPREPLY=( ${COMPREPLY[@]%.template} )
+ fi
+ return 0
+ ;;
+ remove)
+ _filedir
+ COMPREPLY+=( $( compgen -W 'a ap d e f k kde kdei l n t tcl x \
+ xap y' -- "$cur" ) )
+ COMPREPLY+=( $( cd /var/log/packages; compgen -f -- "$cur" ) )
+ return 0
+ ;;
+ install|reinstall|upgrade|blacklist|download)
+ _filedir
+ COMPREPLY+=( $( compgen -W 'a ap d e f k kde kdei l n t tcl x \
+ xap y' -- "$cur" ) )
+ COMPREPLY+=( $( cut -f 6 -d\ ${WORKDIR}/pkglist 2> /dev/null | \
+ grep "^$cur" ) )
+ return 0
+ ;;
+ info)
+ COMPREPLY+=( $( cut -f 6 -d\ ${WORKDIR}/pkglist 2> /dev/null | \
+ grep "^$cur" ) )
+ return 0
+ ;;
+ update)
+ # we should complete the same as the next `list` + "gpg"
+ COMPREPLY=( $( compgen -W 'gpg' -- "$cur" ) )
+ ;&
+ *)
+ COMPREPLY+=( $( compgen -W 'install reinstall upgrade remove \
+ blacklist download update install-new upgrade-all \
+ clean-system new-config check-updates help generate-template \
+ install-template remove-template search file-search info' -- \
+ "$cur" ) )
+ return 0
+ ;;
+ esac
+
+} && complete -F _slackpkg slackpkg
diff --git a/extra/source/bash-completion/contrib/slapt b/extra/source/bash-completion/contrib/slapt
new file mode 100644
index 000000000..779465388
--- /dev/null
+++ b/extra/source/bash-completion/contrib/slapt
@@ -0,0 +1,136 @@
+# slapt-get and slapt-src completion
+
+have slapt-get &&
+_slapt_get()
+{
+ COMPREPLY=()
+ local cur prev
+ _get_comp_words_by_ref cur prev
+
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '--download-only -d --simulate -s \
+ --no-prompt -y --prompt -p --reinstall --ignore-excludes \
+ --no-md5 --ignore-dep --no-dep --print-uris --show-stats -S \
+ --config -c --remove-obsolete --retry --no-upgrade \
+ --update -u --upgrade --dist-upgrade --install -i --install-set \
+ --remove --show --filelist --search --list --available \
+ --installed --clean --autoclean --add-keys \
+ --version --help -h' -- "$cur" ) )
+ return 0
+ fi
+
+ case $prev in
+ --config|-c)
+ _filedir
+ return 0
+ ;;
+ --retry|--search)
+ # argument required but no completions available
+ return 0
+ ;;
+ esac
+
+ local words t
+ _get_comp_words_by_ref words
+
+ # search for last action (--install|--install-set|--remove|--show|--filelist)
+ for (( i=${#words[@]}-1; i>0; i-- )); do
+ if [[ ${words[i]} == -@(i|-install|-show) ]]; then
+ t="all"
+ break
+ elif [[ ${words[i]} == --install-set ]]; then
+ t="set"
+ break
+ elif [[ ${words[i]} == --@(remove|filelist) ]]; then
+ t="ins"
+ break
+ fi
+ done
+
+ case $t in
+ all) # --install|-i|--show
+ # slapt-get will fail to search for "^name-version"
+ # it can search for names only
+ local name=$( echo $cur | cut -f1 -d- )
+ COMPREPLY=( $( slapt-get --search "^$name" 2> /dev/null | \
+ sed -ne "/^$cur/{s/ .*$//;p}" ) )
+ return 0
+ ;;
+ ins) # --remove|--filelist
+ COMPREPLY=( $( cd /var/log/packages; compgen -f -- "$cur" ) )
+ return 0
+ ;;
+ set) # --install-set
+ COMPREPLY=( $( compgen -W 'a ap d e f k kde kdei l n t tcl x \
+ xap y' -- "$cur" ) )
+ return 0
+ ;;
+ esac
+} && complete -F _slapt_get slapt-get
+
+have slapt-src &&
+_slapt_src()
+{
+ COMPREPLY=()
+ local cur prev
+ _get_comp_words_by_ref cur prev
+
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '--update -u --list -l --clean -e \
+ --search -s --show -w --install -i --build -b --fetch -f \
+ --yes -y --config -c --no-dep -n --postprocess -p \
+ --version -v --help -h' -- "$cur" ) )
+ return 0
+ fi
+
+ case $prev in
+ --config|-c)
+ _filedir
+ return 0
+ ;;
+ --search|-s|--postprocess|-p)
+ # argument required but no completions available
+ return 0
+ ;;
+ esac
+
+ local words
+ _get_comp_words_by_ref words
+
+ local t
+ # search for last action (-i|-w|-b|-f)
+ for (( i=${#words[@]}-1; i>0; i-- )); do
+ if [[ ${words[i]} == -@(i|w|f|b|-install|-show|-build|-fetch) ]]; then
+ t="all"
+ break
+ fi
+ done
+ if [ "$t" != "all" ]; then
+ return 0
+ fi
+
+ local config="/etc/slapt-get/slapt-srcrc" # default config location
+ # search for config
+ for (( i=${#words[@]}-1; i>0; i-- )); do
+ if [[ ${words[i]} == -@(c|-config) ]]; then
+ config="${words[i+1]}"
+ break
+ fi
+ done
+ if [ ! -r "$config" ]; then
+ return 0
+ fi
+
+ local builddir=$( sed -ne "/^BUILDDIR=/{s/^BUILDDIR=//;p}" "$config" )
+ if [ ! -d "$builddir" ]; then
+ return 0
+ fi
+
+ local slck_data="${builddir}/slackbuilds_data"
+ if [ ! -r "$slck_data" ]; then
+ return 0
+ fi
+
+ COMPREPLY=( $( sed -ne \
+ "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p}" "$slck_data" ) )
+} && complete -F _slapt_src slapt-src
diff --git a/extra/source/bash-completion/fixup-sh-script-completions.diff b/extra/source/bash-completion/fixup-sh-script-completions.diff
new file mode 100644
index 000000000..15bcf1d1c
--- /dev/null
+++ b/extra/source/bash-completion/fixup-sh-script-completions.diff
@@ -0,0 +1,22 @@
+The 'sh' completion file only completes on *.sh files.
+This breaks the expectation (on Slackware, at least) that
+e.g. "sh /etc/rc.d/rc.my<TAB>" will complete to rc.mysql.
+This patch fixes that, but a consequence is that "sh" will
+complete on *any* filename. IMHO, that's not a regression
+at all, since stock bash without bash-completion does that
+already... --rworkman
+
+Acked-by: volkerdi
+
+diff -Nur bash-completion-1.3.orig/completions/sh bash-completion-1.3/completions/sh
+--- bash-completion-1.3.orig/completions/sh 2011-01-21 03:36:11.000000000 -0600
++++ bash-completion-1.3/completions/sh 2011-03-12 02:06:00.964938285 -0600
+@@ -28,7 +28,7 @@
+ return 0
+ fi
+
+- _filedir sh
++ _filedir
+ } &&
+ complete -F _sh sh
+