begin command-snippets db

command.rec will be stored here, and generate articles.
This commit is contained in:
2026-03-26 22:44:23 +01:00
parent 5f4873fec5
commit c00c9aed16
6 changed files with 85 additions and 65 deletions

View File

@@ -32,9 +32,11 @@ $(foreach dir, $(categories), \
$(eval .dbs/$(dir).rec: $(wildcard $(dir)/*)) \
)
.dbs/:
%/:
mkdir $@
include cmd.mk
$(databases): .dbs/%.rec: %/ | .dbs/
$(info making $(@F))
for entry in $(shell find $< -type f -name "*.md") ; do \

View File

@@ -1,36 +0,0 @@
---
title: "column"
tags: [ "basics", "format", "json" ]
---
Put output into column.
```sh
du -h /etc/* | column
```
Reformat file with an explicit separator (`-s`):
```sh
column -ts: /etc/passwd
```
Give columns names (`-N`), so you can hide some (`-H`):
```sh
column -ts: -N User,PW,UID,GID,Description,Home,shell -H PW,GID /etc/passwd
```
Reorder with `-O` (unspecified items remain):
```sh
column -ts: -N User,PW,UID,GID,Description,Home,shell -H PW,GID -O User,Description,shell /etc/passwd
```
Output to json format with `-J`:
```sh
column -J -ts: -H PW,GID,shell -N User,PW,UID,GID,Description,Home,shell /etc/passwd
```

25
cmd.mk Normal file
View File

@@ -0,0 +1,25 @@
cmds != recsel command.rec -t command -G bin -U -CP bin
lists = $(patsubst %,lists/%.md, $(cmds))
default += $(lists)
get_title = printf 'title: "%s"\n' '${1}'
get_tags = recsel -t $(basename $<) $< -G bin \
-e 'bin = "$(1)"' -U -CP tag | \
sed 's/.*/"&",/g' | \
tr '\n' ' ' | \
sed 's/.*/tags: [ &]/'
list_commands = recsel -t $(basename $<) $< -e 'bin = "$(1)"' | \
recfmt -f lists.fmt
lists/%.md: command.rec | lists/
@printf '%s\n' '---' > $@
@$(call get_title,$(basename $(notdir $@))) >> $@
@$(call get_tags,$(basename $(notdir $@))) >> $@
@printf '\n%s\n' '---' >> $@
@$(call list_commands,$(basename $(notdir $@))) >> $@
.PHONY: cmd
cmd: $(lists) ## Bit lists of commands

51
command.rec Normal file
View File

@@ -0,0 +1,51 @@
%rec: command
%doc: shell command examples
%type: aim line
%allowed: aim cmd bin tag
aim: Put output into column
cmd: du -h /etc/* | column
bin: column
tag: format
aim: Reformat file with an explicit separator (`-s`)
cmd: column -ts: /etc/passwd
bin: column
tag: format
aim: Give columns names (`-N`), so you can hide some (`-H`)
cmd: column -ts: -N User,PW,UID,GID,Description,Home,shell -H PW,GID /etc/passwd
bin: column
tag: format
aim: Reorder with `-O` (unspecified items remain)
cmd: column -ts: -N User,PW,UID,GID,Description,Home,shell -H PW,GID -O User,Description,shell /etc/passwd
bin: column
tag: format
aim: Output to json format with `-J`
cmd: column -J -ts: -H PW,GID,shell -N User,PW,UID,GID,Description,Home,shell /etc/passwd
bin: column
tag: format
tag: json
aim: Make a QR Code image:
cmd: qrencode 'https://play.google.com/store/apps/details?id=org.briarproject.briar.android' -o "$FILE".png
bin: qrencode
tag: qr
aim: Make a QR Coded message in the terminal:
cmd: qrencode -t ansi "Hello World"
bin: qrencode
tag: qr
aim: Read a QR Code image:
cmd: zbarimg $FILE
bin: qrencode
tag: qr
aim: Show wifi QR code (only with Network Manager):
cmd: nmcli device wifi show-password
bin: qrencode
tag: qr
tag: wifi

6
lists.fmt Normal file
View File

@@ -0,0 +1,6 @@
{{aim}}
```{{shell}}
{{cmd}}
```

View File

@@ -1,28 +0,0 @@
---
title: "QR Codes"
tags: [ "qrencode", "zbar" ]
---
Make a QR Code image:
```sh
qrencode 'https://play.google.com/store/apps/details?id=org.briarproject.briar.android' -o "$FILE".png
```
Make a QR Coded message in the terminal:
```sh
qrencode -t ansi "Hello World"
```
Read a QR Code image:
```sh
zbarimg $FILE
```
Show wifi QR code (only with Network Manager):
```sh
nmcli device wifi show-password
```