Skip to content

Instantly share code, notes, and snippets.

@ormaaj
Created November 26, 2012 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ormaaj/4146886 to your computer and use it in GitHub Desktop.
Save ormaaj/4146886 to your computer and use it in GitHub Desktop.
man pager
function man {
if ! command man -W "$@"; then
return 1
elif [[ ! -t 0 ]]; then
echo 'STDIN must be a tty.' >&2
return 1
elif [[ $- != *m* ]]; then
set -m
typeset -f +t "$FUNCNAME"
trap 'trap RETURN; set +m' RETURN
fi
{
{
groffer --text -Tutf8 -rLL=$((${COLUMNS:-$(tput cols)}-10))n -man "$@" 2>/dev/null ||
kill -"$BASHPID"
} | sed -e 's/\x1B\[[[:digit:]]\+m//g' |
vim -c 'set nomod ft=man' --servername manpages --remote -- /dev/fd/4 4<&0 <&3
} 3<&0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment