aboutsummaryrefslogtreecommitdiff
path: root/ponysay
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2012-07-16 11:49:50 +0200
committerMattias Andrée <maandree@operamail.com>2012-07-16 11:49:50 +0200
commit8184d371a984d9a40c70d8a35d059daea5edab0a (patch)
treef979f5a7d48c9da6a7f888d507ab309171f64d89 /ponysay
parentb7cdbf6db2f9d72b17e66ca326d310e6e655fe63 (diff)
downloadponysay-8184d371a984d9a40c70d8a35d059daea5edab0a.tar.gz
ponysay-8184d371a984d9a40c70d8a35d059daea5edab0a.tar.bz2
ponysay-8184d371a984d9a40c70d8a35d059daea5edab0a.zip
ponysay -l is columnated, however a bit slow and limited to 80 in screen width
Diffstat (limited to 'ponysay')
-rwxr-xr-xponysay26
1 files changed, 22 insertions, 4 deletions
diff --git a/ponysay b/ponysay
index 3e2908c..dc36713 100755
--- a/ponysay
+++ b/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
}