-
-
Save RichardBronosky/94024fac52780e03c936589f4c9ab914 to your computer and use it in GitHub Desktop.
A vim wrapper that allow you to use it for a pager, man reader, etc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eu | |
cache_file="/tmp/pager.cache" | |
[[ ! -p "$cache_file" ]] && touch "$cache_file" && trap "rm $cache_file" 0 | |
cat > "$cache_file" | |
vim -R -c "terminal cat $cache_file" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-c "only"
to close windows other than the one containing the terminal output-
to silence theVim: Warning: Input is not from a terminal
and moreover, without this, the terminal gets rather messed up!--not-a-term
to silence theVim: Reading from stdin...
or even better:
vim -R -c "call term_start('cat $cache_file', {'hidden': 1, 'term_finish': 'open', 'term_opencmd': 'buffer %d'})" -
this feels much nicer when used as MANPAGER
the former command leaves us at the bottom of the man page, this one puts us at the top, just like less.
Thanks for the starting point by the way!