aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2022-06-08 15:32:37 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2022-06-08 15:32:37 +0200
commit98934e523c9d05823d7358018017fd880def9716 (patch)
treeb616428c7bdbc83081ed8e92852aba19e091e458 /src
parent6bab41791269c72c7913417e735d06e3e6bf6b56 (diff)
downloadsebastiano.tronto.net-98934e523c9d05823d7358018017fd880def9716.tar.gz
sebastiano.tronto.net-98934e523c9d05823d7358018017fd880def9716.zip
Added blog post. Fixed padding for code in pre.
Diffstat (limited to 'src')
-rw-r--r--src/blog/2022-06-08-more/more.md192
-rw-r--r--src/blog/blog.md1
-rw-r--r--src/blog/feed.xml7
-rw-r--r--src/style-3.css (renamed from src/style-2.css)6
4 files changed, 205 insertions, 1 deletions
diff --git a/src/blog/2022-06-08-more/more.md b/src/blog/2022-06-08-more/more.md
new file mode 100644
index 0000000..3673f59
--- /dev/null
+++ b/src/blog/2022-06-08-more/more.md
@@ -0,0 +1,192 @@
1# The man page reading club: more(1)
2
3In the second episode of this blog series we are going to cover a UNIX
4pager. Instead of the popular less(1), we are going to check out the
5classic more(1).
6
7## In the bunker
8
9*After installing your new OS and checking out the basic documentation,
10you are excited to discover what your laptop can do. But there is
11something keeping you back. Maybe it's the rumors that the nuclear
12winter will be raging for years to come and you are in there for the
13long run. No, it's not that.*
14
15*You feel that learning is fun, and fun is precious, so you should not
16waste it. Entertainment is a scarce resource in the bunker: social
17interactions are awkward, and the battery-charging gym only offers
18re-runs of crappy mainstream reality shows.*
19
20*You dedice to play the slow game and
21[RTFM](https://en.wikipedia.org/wiki/RTFM) some more before doing actual
22work. You have just found out that the man(1) program calls an external
23utility, called less(1), to actually display the page. Learning more
24abut this makes sense.*
25
26```
27$ man less
28```
29
30*You start reading, but you soon feel overwhelmed: this manual page is a
31fucking novel! There are pages and pages of options, and on top of that
32there are commands, and you can't make sense of what is actually useful.
33You scroll back to the top of the page and something catches your eyes:*
34
35```
36less is similar to the traditional more(1), but with many more features.
37```
38
39*Hoping it will be easier to grasp, you decide to look into more(1)*
40
41```
42$ man more
43```
44
45*No, wait! Let's use what we learned [last time](../2022-05-29-man):*
46
47```
48$ PAGER=more man more
49```
50
51## more(1)
52
53*Follow along at [man.openbsd.org](https://man.openbsd.org/OpenBSD-7.1/more)*
54
55The description of more(1) starts with
56
57```
58The more pager displays text one screenful at a time. After showing each
59screenful, it prompts the user for a command. Most commands scroll the text
60or move to a different place in the file, while some switch to another file.
61```
62
63So "commands" seem to be the interesting part. There are also a handful of
64options, but they seem quite technical and not so interesting. Just to name
65a few: `-n` changes the number of lines per screenful, `-p` can be used to
66execute a command when a file is first opened and `-t` can be used to view
67a file containing a specific "tag". This last one is enticing, but it
68redirects to ctags(1), which may be a good topic for a future post.
69
70Let's move on to the juicy part!
71
72```
73COMMANDS
74 Interactive commands for more are based on vi(1). Some commands may be
75 preceded by a decimal number, called N in the descriptions below. In the
76 following descriptions, ^X means control-X.
77```
78
79The first command is `h`, which displays a help page for more(1). It is
80basically a more terse, cheatsheet-like version of the COMMANDS section
81that we are reading.
82
83The basic navigation commands scroll the current page up or down. They can
84all be preceded by the number of lines to be scrolled, but have different
85defaults: `j` (or `RETURN`) scrolls down one line, `k` up one line. `f`
86(or `SPACE`, or `^F`) and `b` (or `^B`) scroll one window down and up,
87respectively. `d` and `u` (or `^D` and `^U`) scroll half a
88window down and up, respectively. It is not documented in the manual, but
89arrow keys, and `PgUp` and `PgDn`, seem to work just fine too.
90
91Perhaps more interestingly, the commands `m` and `'` (single quote) allow
92you to "mark" certain lines and move to them:
93
94```
95m Followed by any lowercase letter, marks the current position with that letter.
96
97' (Single quote.) Followed by any lowercase letter, returns to the position
98 which was previously marked with that letter. Followed by another single
99 quote, returns to the position at whcih the last "large" movement command was
100 executed, or the beginning of the file if no such movements have occurred.
101 All marks are lost when a new file is examined.
102```
103
104There is also a search function:
105
106```
107/pattern Search forward in the file for the N-th line containing the pattern.
108 N defaults to 1. The pattern is a basic regular expression (BRE).
109 See re_format(7) for more information on regular expressions.
110 The search starts at the second line displayed.
111```
112
113Regular expressions are a powerful tool, but we will not see them in detail
114today. For now it is enough to know that plain text is a perfectly fine
115regular expression.
116
117There are alternative commands for searching: using `?` instead of `/`
118searches backwards from the top line, while `/!` and `?!` search for lines
119that *do not* match the pattern. In each case the search command can be
120preceded by a number `N`, meaning we want to find the `N`-th line that
121matches the search. I can see this being useful with `N=2` in case you
122want to find the first next occurrence of a word that appears on the
123current screen. But it is probably easier to just rely on the `n` and `N`
124commands, which simply repeat the previous search, in the same or opposite
125direction respectively; for example, using `N` after a `?` search searches
126for the same pattern *forward*.
127
128The next group of commands is used to move between different files: `:e`
129to open a new one, `:n` for the next file and `:p` for the previous.
130`:t` is used to move between the aforementioned (but not explained) tags.
131
132If you are using more to view a file, the command `v` can be used to edit it,
133using the editor vi(1) by default.
134
135And finally
136
137```
138q | :q | ZZ Exits more.
139```
140
141The last sections are fairly short, but worth skimming through.
142
143The ENVIRONMENT section explains that more can read some environment
144variables to change its behavior. In my opionion the most interesting
145ones are `EDITOR`, which changes the editor to be used with the `v`
146command, and `MORE`, which can be used to set default options for more.
147
148An interesting example in the EXAMPLES section:
149
150```
151Examine several manual pages, starting from the options description in
152the DESCRIPTION section:
153
154 $ more -p '/DESCRIPTION
155 > /options
156 > ' *.1
157```
158
159And a word of warning from the STANDARDS section:
160
161```
162The more utility is compliant with the IEEE Std 1003.1-2008 ("POSIX.1") specification,
163though its presence is optional.
164```
165
166This means that, unfortunately, when dealing with some more obscure POSIX
167operating system you may not have the luxury of a pager program. Too bad.
168
169## Conclusions
170
171It is worth noting that the more(1) manual page states
172
173```
174The present implementation is actually less(1) in disguise.
175```
176
177In practice this means that in OpenBSD, even when using more, one can
178make full use of the extra features of less described in its manual
179page. One of the few differences is how certain options are interpreted.
180
181I originally planned to write about less(1), but I was, as the fictional
182*you* in the nuclear bunker, overwhelmed by the amount of options
183available. Most of them are either quite technical or just change
184slightly the behavior of the pager. Some can be nice, but definitely
185not necessary (e.g. `-P` to change the prompt).
186
187I don't see myself using any of the extra features described in the less(1)
188man page, with the notable exception of the `|` (pipe) command, which
189can be used to pipe arbitrary portions of the current file to an external
190command. But apart from this I could easily live in the pre-1985 era.
191
192See you next time!
diff --git a/src/blog/blog.md b/src/blog/blog.md
index 641b3a0..18b1fbe 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-06-08 [The man page reading club: more(1)](2022-06-08-more)
5* 2022-06-04 [The gemini protocol](2022-06-04-gemini) 6* 2022-06-04 [The gemini protocol](2022-06-04-gemini)
6* 2022-05-29 [The man page reading club: man(1)](2022-05-29-man) 7* 2022-05-29 [The man page reading club: man(1)](2022-05-29-man)
7* 2022-05-21 [Blogs](2022-05-21-blogs) 8* 2022-05-21 [Blogs](2022-05-21-blogs)
diff --git a/src/blog/feed.xml b/src/blog/feed.xml
index f7db1ef..d84e8d5 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>The man page reading club: more(1)</title>
13<link>https://sebastiano.tronto.net/blog/2022-06-08-more</link>
14<description>The man page reading club: more(1)</description>
15<pubDate>2022-06-08</pubDate>
16</item>
17
18<item>
12<title>The gemini protocol</title> 19<title>The gemini protocol</title>
13<link>https://sebastiano.tronto.net/blog/2022-06-04-gemini</link> 20<link>https://sebastiano.tronto.net/blog/2022-06-04-gemini</link>
14<description>The gemini protocol</description> 21<description>The gemini protocol</description>
diff --git a/src/style-2.css b/src/style-3.css
index eac9620..fd4d31f 100644
--- a/src/style-2.css
+++ b/src/style-3.css
@@ -34,7 +34,11 @@ img {
34 34
35code { 35code {
36 background-color: #eeeeee; 36 background-color: #eeeeee;
37 padding: 2px; 37 padding: 2px;
38}
39
40pre code {
41 padding: 0px;
38} 42}
39 43
40pre { 44pre {

Generated with cgit - Back to sebastiano.tronto.net