Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #
- # Smartpage: use the pager only if the output does not fit on the screen
- #
- # This program is using the GNU/GPLv3 License <http://www.gnu.org/licenses/>
- REAL_PAGER="less -r"
- FILE="/tmp/.pager"
- WIDTH="$(stty size | cut -d ' ' -f 2)"
- HEIGHT="$(stty size | cut -d ' ' -f 1)"
- fold -w "$WIDTH" "$@" > "$FILE"
- chmod 600 "$FILE"
- if [ "$(wc -l "$FILE" | cut -d ' ' -f 1)" -lt "$HEIGHT" ] ; then
- cat "$FILE"
- else
- $REAL_PAGER "$FILE"
- fi
- rm "$FILE"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement