diff options
author | Case Duckworth | 2020-05-22 08:38:40 -0500 |
---|---|---|
committer | Case Duckworth | 2020-05-22 08:38:40 -0500 |
commit | 6cce4bd5e7e89406c0ca5942076c95c458bba2dc (patch) | |
tree | 89e5a9393b5c99aa2a6eb0fc87e9e97e7ec84e57 /page | |
download | bollux-6cce4bd5e7e89406c0ca5942076c95c458bba2dc.tar.gz bollux-6cce4bd5e7e89406c0ca5942076c95c458bba2dc.zip |
Ready to upload
Diffstat (limited to 'page')
-rwxr-xr-x | page | 48 |
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 | |||
6 | cleanup() { | ||
7 | tput reset | ||
8 | exit | ||
9 | } | ||
10 | |||
11 | refresh() { | ||
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 | |||
20 | resize() { | ||
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 | |||
32 | main() { | ||
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 | |||
46 | if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then | ||
47 | main "$@" | ||
48 | fi | ||