mirror of
https://github.com/erkin/ponysay.git
synced 2025-02-19 19:04:23 +01:00
support for github.com/maandree/ponyquotes4ponysay
This commit is contained in:
parent
27fbbf1738
commit
e20ae102e5
1 changed files with 47 additions and 4 deletions
51
ponysay
51
ponysay
|
@ -21,13 +21,29 @@ version() {
|
||||||
scrw=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 2`
|
scrw=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 2`
|
||||||
listcmd="$0list.pl"
|
listcmd="$0list.pl"
|
||||||
|
|
||||||
|
haspq=1
|
||||||
|
if [[ -f './pq4ps-list' ]]; then
|
||||||
|
function qlist
|
||||||
|
{ ./pq4ps-list
|
||||||
|
}
|
||||||
|
elif [[ -f '/usr/bin/pq4ps-list' ]]; then
|
||||||
|
function qlist
|
||||||
|
{ /usr/bin/pq4ps-list
|
||||||
|
}
|
||||||
|
else
|
||||||
|
haspq=0
|
||||||
|
function qlist
|
||||||
|
{ cat
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
list() {
|
list() {
|
||||||
echo -e "\\e[01mponyfiles located in $SYSTEMPONIES:\\e[21m"
|
echo -e "\\e[01mponyfiles located in $SYSTEMPONIES:\\e[21m"
|
||||||
perl $listcmd $scrw $(ls --color=no $SYSTEMPONIES | sed -e 's/\.pony$//' | sort)
|
perl $listcmd $scrw $(ls --color=no $SYSTEMPONIES | sed -e 's/\.pony$//' | sort) | qlist
|
||||||
|
|
||||||
if [[ -d $HOMEPONIES ]]; then
|
if [[ -d $HOMEPONIES ]]; then
|
||||||
echo -e "\\e[01mponyfiles located in $HOMEPONIES:\\e[21m"
|
echo -e "\\e[01mponyfiles located in $HOMEPONIES:\\e[21m"
|
||||||
perl $listcmd $scrw $(ls --color=no $HOMEPONIES | sed -e 's/\.pony$//' | sort)
|
perl $listcmd $scrw $(ls --color=no $HOMEPONIES | sed -e 's/\.pony$//' | sort) | qlist
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +132,7 @@ while (\$i < \$argc)
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
perl $listcmd $scrw $(cat /dev/shm/ponysay~) | sed -e 's/_/ /g'
|
perl $listcmd $scrw $(cat /dev/shm/ponysay~) | sed -e 's/_/ /g' | qlist
|
||||||
}
|
}
|
||||||
|
|
||||||
linklist() {
|
linklist() {
|
||||||
|
@ -140,6 +156,13 @@ Options:
|
||||||
-h Show this help and exit.
|
-h Show this help and exit.
|
||||||
-l List pony files.
|
-l List pony files.
|
||||||
-L List pony files with synonyms inside brackets.
|
-L List pony files with synonyms inside brackets.
|
||||||
|
EOF
|
||||||
|
if [[ $haspq = 1 ]]; then
|
||||||
|
cat <<EOF
|
||||||
|
-q Use the pony quote feature.
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
cat <<EOF
|
||||||
-f[name] Select a pony (either a file name or a pony name.)
|
-f[name] Select a pony (either a file name or a pony name.)
|
||||||
-W[column] The screen column where the message should be wrapped.
|
-W[column] The screen column where the message should be wrapped.
|
||||||
|
|
||||||
|
@ -199,7 +222,12 @@ say() {
|
||||||
|
|
||||||
ponies=()
|
ponies=()
|
||||||
|
|
||||||
while getopts f:W:Llhv OPT
|
opts="f:W:Llhv"
|
||||||
|
if [[ $haspq ]]; then
|
||||||
|
opts=$opts"q"
|
||||||
|
fi
|
||||||
|
usepq=0
|
||||||
|
while getopts $opts OPT
|
||||||
do
|
do
|
||||||
case ${OPT} in
|
case ${OPT} in
|
||||||
v) version; exit ;;
|
v) version; exit ;;
|
||||||
|
@ -208,11 +236,26 @@ do
|
||||||
l) list; exit ;;
|
l) list; exit ;;
|
||||||
L) linklist; exit ;;
|
L) linklist; exit ;;
|
||||||
W) wrap="$OPTARG" ;;
|
W) wrap="$OPTARG" ;;
|
||||||
|
q) usepq=1 ;;
|
||||||
\?) usage >&2; exit 1 ;;
|
\?) usage >&2; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $((OPTIND - 1))
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
|
if [[ $usepq = 1 ]]; then
|
||||||
|
if [[ -f './pq4ps' ]]; then
|
||||||
|
function q
|
||||||
|
{ ./pq4ps $@
|
||||||
|
}
|
||||||
|
elif [[ -f '/usr/bin/pq4ps' ]]; then
|
||||||
|
function q
|
||||||
|
{ /usr/bin/pq4ps $@
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
$0 ${wrap:+-W$wrap} $(q "$*")
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
hash $cmd &>/dev/null; if [ $? -ne 0 ]; then
|
hash $cmd &>/dev/null; if [ $? -ne 0 ]; then
|
||||||
cat >&2 <<EOF
|
cat >&2 <<EOF
|
||||||
You don't seem to have the $cmd program.
|
You don't seem to have the $cmd program.
|
||||||
|
|
Loading…
Reference in a new issue