rand/gentoo-packages/app-paludis/plop/files/plop.bash-completion
Martin Sekera 2d2bbbc830 - migrated to Exherbo
- added a few initial Pantheon components
2018-12-08 23:26:56 +01:00

60 lines
2.2 KiB
Bash

# -*- shell-script -*-
# If you have bash completion installed and want plop to auto-complete
# packages, save this file as /etc/bash_completion.d/plop
#
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
#
# Author: Geert Bevin <gbevin@theleaf.be>
# Author: Zach Forrest <zach@disinformation.ca>
#
# Adapted for genlop by Giorgio Mandolfo <giorgio@pollycoke.org>
# Adapted for plop by Tobias Hommel <software@genoetigt.de>
#
_plop()
{
local cur grepcmd sedcmd systemactions setsma setbig portagedir origdir
origdir="${PWD}"
COMPREPLY=()
# whoa, what a funny construction
portagedir="$( echo `eval echo $(grep '^location' /etc/paludis/repositories/gentoo.conf|sed 's/^location = \(.*\)/\1/')` )"
if [ -z "${portagedir}" ]; then
portagedir=/usr/portage
fi
cur="${COMP_WORDS[COMP_CWORD]}"
cd "${portagedir}"
grepcmd="grep -E ^${cur}.*"
sedcmd="sed -e /^[^-]*$/d"
case "$cur" in
-*)
COMPREPLY=( $( compgen -W '--current --file --help \
--info --gmt --list --nocolor --pretend --rsync \
--search --time --unmerge --version' -- $cur ) )
;;
*)
if [ "${cur}" ]; then
if [ $(echo "${cur}" | grep '/') ]; then
setbig=$(compgen -G "${cur}*" | ${sedcmd})"${systemactions}"
COMPREPLY=($(echo "${setbig}" | $grepcmd))
else
setsma=$(compgen -S '/' -G "${cur}*" | ${sedcmd})"${systemactions}"
if [ $(echo "${setsma}" | ${grepcmd} | grep '/' | wc -l) = 1 ]; then
setbig=$(compgen -G "*/*" | ${sedcmd})"${systemactions}"
COMPREPLY=($(echo "${setbig}" | ${grepcmd}))
else
COMPREPLY=($(echo "${setsma}" | ${grepcmd}))
fi
fi
else
setsma=$(compgen -S '/' -G "${cur}*" | ${sedcmd})"${systemactions}"
COMPREPLY=($(echo "${setsma}"))
fi
;;
esac
cd "${origdir}"
return 0
}
complete -o default -F _plop plop