mirror of
https://github.com/erkin/ponysay.git
synced 2024-11-28 23:17:59 +01:00
ponysay -l is columnated, however a bit slow and limited to 80 in screen width
This commit is contained in:
parent
b7cdbf6db2
commit
8184d371a9
1 changed files with 22 additions and 4 deletions
26
ponysay
26
ponysay
|
@ -19,11 +19,29 @@ version() {
|
|||
}
|
||||
|
||||
list() {
|
||||
echo "ponyfiles located in $SYSTEMPONIES:"
|
||||
ls -1 $SYSTEMPONIES | sed "s/.pony//"
|
||||
scrw=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 2`
|
||||
(( $scrw > 80 )) && scrw=80
|
||||
|
||||
echo -e "\\e[01mponyfiles located in $SYSTEMPONIES:\\e[21m"
|
||||
files=`ls -1 $SYSTEMPONIES | sed "s/.pony//"`
|
||||
maxw=1
|
||||
for file in $files; do
|
||||
w=$(( `echo $file | wc -m` + 2 ))
|
||||
(( $maxw < $w )) && maxw=$w
|
||||
done
|
||||
cols=$(( $scrw / $maxw ))
|
||||
echo "$files" | pr -T --columns=$cols
|
||||
|
||||
if [[ -d $HOMEPONIES ]]; then
|
||||
echo "ponyfiles located in $HOMEPONIES:"
|
||||
ls -1 $HOMEPONIES | sed "s/.pony//"
|
||||
echo -e "\\e[01mponyfiles located in $HOMEPONIES:\\e[21m"
|
||||
files=`ls -1 $HOMEPONIES | sed "s/.pony//"`
|
||||
maxw=1
|
||||
for file in $files; do
|
||||
w=$(( `echo $file | wc -m` ))
|
||||
(( $maxw < $w )) && maxw=$w
|
||||
done
|
||||
cols=$(( $scrw / $maxw ))
|
||||
echo "$files" | pr -T --columns=$cols
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue