#!/bin/sh
# Set this as your pager via the PAGER environment variable. Works great with
# man and every other app that has used it so far.
# Uses my pager.vim macro which just tweaks the vim settings to behave in a
# more pager like way. Get the pager.vim macro and put it in ~/.vim/macros/.
#
# For man pages I also have a man_title.vim a filetype plugin which places the
# man page's topic in the x-terminal's titlebar. Just put it in
# ~/.vim/ftplugin/.
#
# The pager.vim macro and man_title.vim plugin should be available on my site
# (probably right next to where you got this) at
# . If not there look around for a vim area,
# I'm thinking about created one.
# 0 - stdin
# 1 - stdout
# 2 - stderr
g=""
[ $# -gt 0 ] && [ $1 = "-g" ] && g="g" && shift
if [ -t 0 ]; then
# stdin is open (file on command line)
exec ${g}view -c 'runtime! macros/pager.vim' $@
elif [ -t 1 ]; then
# stdin closed (0) but stdout open
# piped input (eg. man viewer)
if [ $# -gt 0 ] && [ "$1" = "-m" ]; then
# -m indicates man page
exec col -b | ${g}view -c 'runtime! macros/pager.vim' -c "set ft=man" -
else
exec ${g}view -c 'runtime! macros/pager.vim' -
fi
else
# man w/ piped output
exec cat
fi
# stuff I was testing.
# need to get this in a vcs so I delete crap like this...
#
# view --cmd 'let no_plugin_maps = 1' \
# -c 'set nomod nolist ignorecase wrapscan' \
# col -b | view --cmd 'let no_plugin_maps = 1' \
# -c 'set ft=man nomod nolist ignorecase wrapscan' \
# -c "set ls=2" -c 'noremap ' -c 'noremap ' -