diff --git a/Makefile b/Makefile index 4f256b0..34cefaa 100644 --- a/Makefile +++ b/Makefile @@ -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 \ diff --git a/basics/column.md b/basics/column.md deleted file mode 100644 index 2738a14..0000000 --- a/basics/column.md +++ /dev/null @@ -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 -``` - diff --git a/cmd.mk b/cmd.mk new file mode 100644 index 0000000..552d6f0 --- /dev/null +++ b/cmd.mk @@ -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 diff --git a/command.rec b/command.rec new file mode 100644 index 0000000..15c9f01 --- /dev/null +++ b/command.rec @@ -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 diff --git a/lists.fmt b/lists.fmt new file mode 100644 index 0000000..6bb67b5 --- /dev/null +++ b/lists.fmt @@ -0,0 +1,6 @@ + +{{aim}} + +```{{shell}} +{{cmd}} +``` diff --git a/vision/qr_codes.md b/vision/qr_codes.md deleted file mode 100644 index 24e4b22..0000000 --- a/vision/qr_codes.md +++ /dev/null @@ -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 -```