aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/blog/2022-05-29-man/man.md15
-rw-r--r--src/blog/2022-09-05-man-col/man-col.md74
-rw-r--r--src/blog/blog.md1
-rw-r--r--src/blog/feed.xml7
4 files changed, 97 insertions, 0 deletions
diff --git a/src/blog/2022-05-29-man/man.md b/src/blog/2022-05-29-man/man.md
index bfb1a26..26cad6b 100644
--- a/src/blog/2022-05-29-man/man.md
+++ b/src/blog/2022-05-29-man/man.md
@@ -246,3 +246,18 @@ here, such as `less(1)`, or dive into more exciting stuff with something
246like `sh(1)`. 246like `sh(1)`.
247 247
248Stay tuned! 248Stay tuned!
249
250## Update 2022-09-05
251
252In [a more recent blog post](../2022-09-05-man-col) I comment on a part
253of the manual that I skipped, although it is actually useful for writing
254these blog entries:
255
256```
257When using -c, most terminal devices are unable to show the
258markup. To print the output of man to the terminal with markup
259but without using a pager, pipe it to ul(1). To remove the
260markup, pipe the output to col(1) -b instead.
261```
262
263If you are curious, check the [new post](../2022-09-05-man-col)!
diff --git a/src/blog/2022-09-05-man-col/man-col.md b/src/blog/2022-09-05-man-col/man-col.md
new file mode 100644
index 0000000..e5f1b44
--- /dev/null
+++ b/src/blog/2022-09-05-man-col/man-col.md
@@ -0,0 +1,74 @@
1# Pipe man into col -b to get rid of ^H
2
3The man page reading club is returning soon. In the meantime,
4here is a short post on a trick related to `man` itself that I skipped in the
5[first post of the series](../2022-05-29-man).
6
7## Vi rocks
8
9A cool feature of vi-like editors is that you can insert the
10output a command in the file you are editing, without doing any awkard
11copy-pasting. You can do this with the `r` ex command:
12
13```
14:r !date
15```
16
17Inserts the output of the `date` command on a new line. You can also
18use the `!` (bang) command, combined with a motion, to feed the
19text between the cursor and the target of the motion to a command and
20replace it with the output of the command itself. For example
21I often use `!}fmt` to format the next paragraph when I am writing
22an email.
23
24## Man pages and ANSI escape codes
25
26Unfortunately, if you try to use this feature to include parts of a man page,
27you might not like the result. Typing `:r !man man | head` gives
28
29```
30MAN(1) General Commands Manual MAN(1)
31
32N^HNA^HAM^HME^HE
33 m^Hma^Han^Hn - display manual pages
34
35S^HSY^HYN^HNO^HOP^HPS^HSI^HIS^HS
36 m^Hma^Han^Hn [-^H-a^Hac^Hcf^Hfh^Hhk^Hkl^Hlw^Hw] [-^H-C^HC _^Hf_^Hi_^Hl_^He] [-^H-M^HM _^Hp_^Ha_^Ht_^Hh] [-^H-m^Hm _^Hp_^Ha_^Ht_^Hh] [-^H-S^HS _^Hs_^Hu_^Hb_^Hs_^He_^Hc_^Ht_^Hi_^Ho_^Hn]
37 [[-^H-s^Hs] _^Hs_^He_^Hc_^Ht_^Hi_^Ho_^Hn] _^Hn_^Ha_^Hm_^He _^H._^H._^H.
38
39D^HDE^HES^HSC^HCR^HRI^HIP^HPT^HTI^HIO^HON^HN
40```
41
42Not cool! This happens because manual pages are not made of plain text. They
43contain *ANSI escape codes* to provide some basic formatting, like
44bold text and whatnot (you might or might not see them, depending on the
45capabilities of your terminal emulator). This is a complex topic and I don't
46know much about it. Check out the excellent post
47[Anatomy of a Terminal Emulator](https://poor.dev/terminal-anatomy)
48by [poor.dev](https://poor.dev) if you want to learn more.
49
50Long story short, the workaround is included in the man page itself:
51
52```
53When using -c, most terminal devices are unable to show the
54markup. To print the output of man to the terminal with markup
55but without using a pager, pipe it to ul(1). To remove the
56markup, pipe the output to col(1) -b instead.
57```
58
59Indeed, using `:r !man man | col -b | head` gives:
60
61```
62MAN(1) General Commands Manual MAN(1)
63
64NAME
65 man - display manual pages
66
67SYNOPSIS
68 man [-acfhklw] [-C file] [-M path] [-m path] [-S subsection]
69 [[-s] section] name ...
70
71DESCRIPTION
72```
73
74Hooray!
diff --git a/src/blog/blog.md b/src/blog/blog.md
index 52673bf..0da77e0 100644
--- a/src/blog/blog.md
+++ b/src/blog/blog.md
@@ -2,6 +2,7 @@
2 2
3[RSS Feed](feed.xml) 3[RSS Feed](feed.xml)
4 4
5* 2022-09-05 [Pipe man into col -b to get rid of ^H](2022-09-05-man-col)
5* 2022-08-14 [How I update my website](2022-08-14-website) 6* 2022-08-14 [How I update my website](2022-08-14-website)
6* 2022-07-07 [The man page reading club: shutdown(8)](2022-07-07-shutdown) 7* 2022-07-07 [The man page reading club: shutdown(8)](2022-07-07-shutdown)
7* 2022-06-12 [The UNIX shell as an IDE: look stuff up with sed](2022-06-12-shell-ide-sed) 8* 2022-06-12 [The UNIX shell as an IDE: look stuff up with sed](2022-06-12-shell-ide-sed)
diff --git a/src/blog/feed.xml b/src/blog/feed.xml
index 2e3382e..9596fb7 100644
--- a/src/blog/feed.xml
+++ b/src/blog/feed.xml
@@ -9,6 +9,13 @@ Thoughts about software, computers and whatever I feel like sharing
9</description> 9</description>
10 10
11<item> 11<item>
12<title>Pipe man into col -b to get rid of ^H</title>
13<link>https://sebastiano.tronto.net/blog/2022-09-05-man-col</link>
14<description>Pipe man into col -b to get rid of ^H</description>
15<pubDate>2022-09-05</pubDate>
16</item>
17
18<item>
12<title>How I update my website</title> 19<title>How I update my website</title>
13<link>https://sebastiano.tronto.net/blog/2022-08-14-website</link> 20<link>https://sebastiano.tronto.net/blog/2022-08-14-website</link>
14<description>How I update my website</description> 21<description>How I update my website</description>

Generated with cgit - Back to sebastiano.tronto.net