cowsay/cowsay.bashcomp
Hans Ulrich Niedermann 5d32962217 Fix bash completion to look in actual cow directories
Fix bash completion to look in the actual cows/ directory.

It appears that cowsay used to store its cows in
/usr/share/cowsay and that is where the cowsay.bashcomp
file also looked. However, cowsay now stores its cows in
/usr/share/cowsay/cows, so the bash completion should look
there as well.

Note that the bash completion should also look into
/usr/share/cowsay/site-cows/ and wherever else cowsay
looks for cows.
2022-08-15 10:34:28 +02:00

34 lines
1 KiB
Bash

# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/www/viewcvs.gentoo.org/raw_cvs/gentoo-x86/games-misc/cowsay/files/cowsay.bashcomp,v 1.1 2005/02/06 14:37:54 ka0ttic Exp $
# bash command-line completion for cowsay
# Author: Aaron Walker <ka0ttic@gentoo.org>
# Modified by: Michal Bentkowski <mr.ecik at gmail.com>
_cowsay() {
local cur prev opts x
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-e -f -h -l -n -T -W -b -d -g -p -s -t -w -y"
if [[ "${cur}" == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
case "${prev}" in
-f)
COMPREPLY=( $( command ls /usr/share/cowsay/cows| \
sed -ne 's|^\('$cur'.*\)\.cow$|\1|p') )
return 0
;;
-[eTW])
COMPREPLY=()
;;
esac
}
complete -o filenames -F _cowsay cowsay cowthink
# vim: set ft=sh tw=80 sw=4 et :