1 |
commit: 65f60cb497c44cc45f0e02f3661cfce3c5661e2c |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Aug 30 03:14:50 2015 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Aug 30 03:15:41 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=65f60cb4 |
7 |
|
8 |
app-text/manpager: initial package #184604 |
9 |
|
10 |
Simple wrapper for colorizing man page output. |
11 |
|
12 |
app-text/manpager/files/manpager.c | 74 +++++++++++++++++++++++++++++++++++++ |
13 |
app-text/manpager/manpager-1.ebuild | 32 ++++++++++++++++ |
14 |
app-text/manpager/metadata.xml | 5 +++ |
15 |
3 files changed, 111 insertions(+) |
16 |
|
17 |
diff --git a/app-text/manpager/files/manpager.c b/app-text/manpager/files/manpager.c |
18 |
new file mode 100644 |
19 |
index 0000000..99b0680 |
20 |
--- /dev/null |
21 |
+++ b/app-text/manpager/files/manpager.c |
22 |
@@ -0,0 +1,74 @@ |
23 |
+/* |
24 |
+ * Wrapper to help enable colorized man page output. |
25 |
+ * Only works with PAGER=less |
26 |
+ * |
27 |
+ * https://bugs.gentoo.org/184604 |
28 |
+ * https://unix.stackexchange.com/questions/108699/documentation-on-less-termcap-variables |
29 |
+ * |
30 |
+ * Copyright 2003-2015 Gentoo Foundation |
31 |
+ * Distributed under the terms of the GNU General Public License v2 |
32 |
+ */ |
33 |
+ |
34 |
+#include <stdio.h> |
35 |
+#include <stdlib.h> |
36 |
+#include <string.h> |
37 |
+#include <unistd.h> |
38 |
+ |
39 |
+#define COLOR(c, b) "\e[" #c ";" #b "m" |
40 |
+ |
41 |
+#define _SE(termcap, col) setenv("LESS_TERMCAP_" #termcap, col, 0) |
42 |
+#define SE(termcap, c, b) _SE(termcap, COLOR(c, b)) |
43 |
+ |
44 |
+static int usage(void) |
45 |
+{ |
46 |
+ puts( |
47 |
+ "manpager: display man pages with color!\n" |
48 |
+ "\n" |
49 |
+ "Usage:\n" |
50 |
+ "\texport MANPAGER=manpager\n" |
51 |
+ "\tman man\n" |
52 |
+ "\n" |
53 |
+ "To control the colorization, set these env vars:\n" |
54 |
+ "\tLESS_TERMCAP_mb - start blinking\n" |
55 |
+ "\tLESS_TERMCAP_md - start bolding\n" |
56 |
+ "\tLESS_TERMCAP_me - stop bolding\n" |
57 |
+ "\tLESS_TERMCAP_us - start underlining\n" |
58 |
+ "\tLESS_TERMCAP_ue - stop underlining\n" |
59 |
+ "\tLESS_TERMCAP_so - start standout (reverse video)\n" |
60 |
+ "\tLESS_TERMCAP_se - stop standout (reverse video)\n" |
61 |
+ "\n" |
62 |
+ "You can do so by doing:\n" |
63 |
+ "\texport LESS_TERMCAP_md=\"$(printf '\\e[1;36m')\"\n" |
64 |
+ "\n" |
65 |
+ "Run 'less --help' or 'man less' for more info" |
66 |
+ ); |
67 |
+ return 0; |
68 |
+} |
69 |
+ |
70 |
+int main(int argc, char *argv[]) |
71 |
+{ |
72 |
+ if (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))) |
73 |
+ return usage(); |
74 |
+ |
75 |
+ /* Blinking. */ |
76 |
+ SE(mb, 5, 31); /* Start. */ |
77 |
+ |
78 |
+ /* Bolding. */ |
79 |
+ SE(md, 1, 34); /* Start. */ |
80 |
+ SE(me, 0, 0); /* Stop. */ |
81 |
+ |
82 |
+ /* Underlining. */ |
83 |
+ SE(us, 4, 36); /* Start. */ |
84 |
+ SE(ue, 0, 0); /* Stop. */ |
85 |
+ |
86 |
+#if 0 |
87 |
+ /* Standout (reverse video). */ |
88 |
+ SE(so, 1, 32); /* Start. */ |
89 |
+ SE(se, 0, 0); /* Stop. */ |
90 |
+#endif |
91 |
+ |
92 |
+ argv[0] = getenv("PAGER") ? : "less"; |
93 |
+ execvp(argv[0], argv); |
94 |
+ perror("could not launch PAGER"); |
95 |
+ return 1; |
96 |
+} |
97 |
|
98 |
diff --git a/app-text/manpager/manpager-1.ebuild b/app-text/manpager/manpager-1.ebuild |
99 |
new file mode 100644 |
100 |
index 0000000..9fd9c26 |
101 |
--- /dev/null |
102 |
+++ b/app-text/manpager/manpager-1.ebuild |
103 |
@@ -0,0 +1,32 @@ |
104 |
+# Copyright 1999-2015 Gentoo Foundation |
105 |
+# Distributed under the terms of the GNU General Public License v2 |
106 |
+# $Id$ |
107 |
+ |
108 |
+EAPI="5" |
109 |
+ |
110 |
+inherit toolchain-funcs |
111 |
+ |
112 |
+DESCRIPTION="Enable colorization of man pages" |
113 |
+HOMEPAGE="http://www.gentoo.org/" |
114 |
+ |
115 |
+LICENSE="GPL-2" |
116 |
+SLOT="0" |
117 |
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86" |
118 |
+IUSE="" |
119 |
+ |
120 |
+S=${WORKDIR} |
121 |
+ |
122 |
+src_compile() { |
123 |
+ local cmd=( |
124 |
+ $(tc-getCC) ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} |
125 |
+ "${FILESDIR}"/manpager.c -o ${PN} |
126 |
+ ) |
127 |
+ echo "${cmd[@]}" |
128 |
+ "${cmd[@]}" || die |
129 |
+} |
130 |
+ |
131 |
+src_install() { |
132 |
+ dobin ${PN} |
133 |
+ insinto /etc/env.d |
134 |
+ echo "MANPAGER=manpager" | newins - 00manpager |
135 |
+} |
136 |
|
137 |
diff --git a/app-text/manpager/metadata.xml b/app-text/manpager/metadata.xml |
138 |
new file mode 100644 |
139 |
index 0000000..96a2d58 |
140 |
--- /dev/null |
141 |
+++ b/app-text/manpager/metadata.xml |
142 |
@@ -0,0 +1,5 @@ |
143 |
+<?xml version="1.0" encoding="UTF-8"?> |
144 |
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> |
145 |
+<pkgmetadata> |
146 |
+<herd>base-system</herd> |
147 |
+</pkgmetadata> |