about summary refs log tree commit diff stats
path: root/page
diff options
context:
space:
mode:
Diffstat (limited to 'page')
-rwxr-xr-xpage48
1 files changed, 48 insertions, 0 deletions
diff --git a/page b/page new file mode 100755 index 0000000..c478d7a --- /dev/null +++ b/page
@@ -0,0 +1,48 @@
1#!/bin/bash
2# pager
3
4. ./wrap
5
6cleanup() {
7 tput reset
8 exit
9}
10
11refresh() {
12 shopt -s checkwinsize
13 (
14 :
15 :
16 )
17 printf '\e[?1049h\e?7l\e[2J\e[3;%sr\e[999H' "$((LINES - 1))"
18}
19
20resize() {
21 refresh
22
23 printf '\e7\e[?25l\e[H'
24 _wrap "$file"
25 printf '\e[999H\e[?25h'
26}
27
28_wrap() {
29 wrap "$COLUMNS" <"$1"
30}
31
32main() {
33 refresh
34
35 file="$1"
36 resize
37
38 trap resize WINCH
39 trap cleanup INT
40
41 while :; do
42 :
43 done
44}
45
46if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
47 main "$@"
48fi