colored-man-pages.plugin.zsh 868 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. if [[ "$OSTYPE" = solaris* ]]
  2. then
  3. if [[ ! -x "$HOME/bin/nroff" ]]
  4. then
  5. mkdir -p "$HOME/bin"
  6. cat > "$HOME/bin/nroff" <<EOF
  7. #!/bin/sh
  8. if [ -n "\$_NROFF_U" -a "\$1,\$2,\$3" = "-u0,-Tlp,-man" ]; then
  9. shift
  10. exec /usr/bin/nroff -u\$_NROFF_U "\$@"
  11. fi
  12. #-- Some other invocation of nroff
  13. exec /usr/bin/nroff "\$@"
  14. EOF
  15. chmod +x "$HOME/bin/nroff"
  16. fi
  17. fi
  18. function colored() {
  19. command env \
  20. LESS_TERMCAP_mb=$(printf "\e[1;31m") \
  21. LESS_TERMCAP_md=$(printf "\e[1;31m") \
  22. LESS_TERMCAP_me=$(printf "\e[0m") \
  23. LESS_TERMCAP_se=$(printf "\e[0m") \
  24. LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
  25. LESS_TERMCAP_ue=$(printf "\e[0m") \
  26. LESS_TERMCAP_us=$(printf "\e[1;32m") \
  27. PAGER="${commands[less]:-$PAGER}" \
  28. _NROFF_U=1 \
  29. PATH="$HOME/bin:$PATH" \
  30. "$@"
  31. }
  32. # Colorize man and dman/debman (from debian-goodies)
  33. function man \
  34. dman \
  35. debman {
  36. colored $0 "$@"
  37. }