Created
November 26, 2012 06:43
-
-
Save ormaaj/4146886 to your computer and use it in GitHub Desktop.
man pager
This file contains 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
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