aboutsummaryrefslogtreecommitdiffstats
path: root/man/colourised-less-for-man
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-11-18 23:23:40 +0100
committerMattias Andrée <maandree@kth.se>2023-11-18 23:23:40 +0100
commit0f1df0db903ba576fd17b08197d3066af7a61e5f (patch)
treea59c04307b1382257afa3c3512ec3abadf7e0e47 /man/colourised-less-for-man
parentUse losetup -d instead of --detach and add clean up (diff)
downloaddotfiles-0f1df0db903ba576fd17b08197d3066af7a61e5f.tar.gz
dotfiles-0f1df0db903ba576fd17b08197d3066af7a61e5f.tar.bz2
dotfiles-0f1df0db903ba576fd17b08197d3066af7a61e5f.tar.xz
A lot of changes
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rwxr-xr-xman/colourised-less-for-man22
1 files changed, 22 insertions, 0 deletions
diff --git a/man/colourised-less-for-man b/man/colourised-less-for-man
new file mode 100755
index 0000000..e57fa18
--- /dev/null
+++ b/man/colourised-less-for-man
@@ -0,0 +1,22 @@
+#!/bin/dash
+
+colourise () {
+ if test -n "$2"; then
+ from="$(printf "$1"'\n' | sed 's/\[/\\[/g')"
+ to="$(printf '%s\n' "$2" | sed 's/\[/\\[/g')"
+ shift 2
+ sed "s/$from/$to/g" | "$@"
+ else
+ shift 2
+ "$@"
+ fi
+}
+
+sed 's/\x1B\[\(.\)m\x1B\[2\(.\)m/\x1B\[2\2m\x1B\[\1m/g' | \
+colourise "\033[4m" "${LESS_TERMCAP_us}" \
+colourise "\033[24m" "${LESS_TERMCAP_ue}" \
+colourise "\033[1m" "${LESS_TERMCAP_md}" \
+colourise "\033[22m" "${LESS_TERMCAP_me}" \
+colourise "\033[7m" "${LESS_TERMCAP_so}" \
+colourise "\033[27m" "${LESS_TERMCAP_se}" \
+less "$@"