Skip to content

Instantly share code, notes, and snippets.

@malko
Last active December 14, 2015 23:49
Show Gist options
  • Select an option

  • Save malko/5168571 to your computer and use it in GitHub Desktop.

Select an option

Save malko/5168571 to your computer and use it in GitHub Desktop.
simple shell program to launch pager (most for now) only if input datas won't fit into screen
#!/bin/bash
pgr="most"
tmpFile="/tmp/pager_$(uuidgen)"
cat - /dev/stdin > $tmpFile;
nblines=$(wc -l $tmpFile |awk '{print($1)}');
if [ "$nblines" -gt "$(tput lines)" ]; then
$pgr $tmpFile
else
cat $tmpFile && echo ""
fi
rm $tmpFile;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment