diff options
author | Mike Frysinger <vapier@gentoo.org> | 2015-08-29 23:14:50 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2015-08-29 23:15:41 -0400 |
commit | 65f60cb497c44cc45f0e02f3661cfce3c5661e2c (patch) | |
tree | d497262d2a692aec1bb3122ef7719f8b19a060bd | |
parent | dev-python/selenium; bump, remove unneeded IUSE doc (diff) | |
download | gentoo-65f60cb497c44cc45f0e02f3661cfce3c5661e2c.tar.gz gentoo-65f60cb497c44cc45f0e02f3661cfce3c5661e2c.tar.bz2 gentoo-65f60cb497c44cc45f0e02f3661cfce3c5661e2c.zip |
app-text/manpager: initial package #184604
Simple wrapper for colorizing man page output.
-rw-r--r-- | app-text/manpager/files/manpager.c | 74 | ||||
-rw-r--r-- | app-text/manpager/manpager-1.ebuild | 32 | ||||
-rw-r--r-- | app-text/manpager/metadata.xml | 5 |
3 files changed, 111 insertions, 0 deletions
diff --git a/app-text/manpager/files/manpager.c b/app-text/manpager/files/manpager.c new file mode 100644 index 000000000000..99b0680a1d83 --- /dev/null +++ b/app-text/manpager/files/manpager.c @@ -0,0 +1,74 @@ +/* + * Wrapper to help enable colorized man page output. + * Only works with PAGER=less + * + * https://bugs.gentoo.org/184604 + * https://unix.stackexchange.com/questions/108699/documentation-on-less-termcap-variables + * + * Copyright 2003-2015 Gentoo Foundation + * Distributed under the terms of the GNU General Public License v2 + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#define COLOR(c, b) "\e[" #c ";" #b "m" + +#define _SE(termcap, col) setenv("LESS_TERMCAP_" #termcap, col, 0) +#define SE(termcap, c, b) _SE(termcap, COLOR(c, b)) + +static int usage(void) +{ + puts( + "manpager: display man pages with color!\n" + "\n" + "Usage:\n" + "\texport MANPAGER=manpager\n" + "\tman man\n" + "\n" + "To control the colorization, set these env vars:\n" + "\tLESS_TERMCAP_mb - start blinking\n" + "\tLESS_TERMCAP_md - start bolding\n" + "\tLESS_TERMCAP_me - stop bolding\n" + "\tLESS_TERMCAP_us - start underlining\n" + "\tLESS_TERMCAP_ue - stop underlining\n" + "\tLESS_TERMCAP_so - start standout (reverse video)\n" + "\tLESS_TERMCAP_se - stop standout (reverse video)\n" + "\n" + "You can do so by doing:\n" + "\texport LESS_TERMCAP_md=\"$(printf '\\e[1;36m')\"\n" + "\n" + "Run 'less --help' or 'man less' for more info" + ); + return 0; +} + +int main(int argc, char *argv[]) +{ + if (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))) + return usage(); + + /* Blinking. */ + SE(mb, 5, 31); /* Start. */ + + /* Bolding. */ + SE(md, 1, 34); /* Start. */ + SE(me, 0, 0); /* Stop. */ + + /* Underlining. */ + SE(us, 4, 36); /* Start. */ + SE(ue, 0, 0); /* Stop. */ + +#if 0 + /* Standout (reverse video). */ + SE(so, 1, 32); /* Start. */ + SE(se, 0, 0); /* Stop. */ +#endif + + argv[0] = getenv("PAGER") ? : "less"; + execvp(argv[0], argv); + perror("could not launch PAGER"); + return 1; +} diff --git a/app-text/manpager/manpager-1.ebuild b/app-text/manpager/manpager-1.ebuild new file mode 100644 index 000000000000..9fd9c2672166 --- /dev/null +++ b/app-text/manpager/manpager-1.ebuild @@ -0,0 +1,32 @@ +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +EAPI="5" + +inherit toolchain-funcs + +DESCRIPTION="Enable colorization of man pages" +HOMEPAGE="http://www.gentoo.org/" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86" +IUSE="" + +S=${WORKDIR} + +src_compile() { + local cmd=( + $(tc-getCC) ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} + "${FILESDIR}"/manpager.c -o ${PN} + ) + echo "${cmd[@]}" + "${cmd[@]}" || die +} + +src_install() { + dobin ${PN} + insinto /etc/env.d + echo "MANPAGER=manpager" | newins - 00manpager +} diff --git a/app-text/manpager/metadata.xml b/app-text/manpager/metadata.xml new file mode 100644 index 000000000000..96a2d586367d --- /dev/null +++ b/app-text/manpager/metadata.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> +<herd>base-system</herd> +</pkgmetadata> |