Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
f4f6da1250
|
|||
|
f47a28b359
|
|||
|
77af4be50c
|
|||
|
5cae2da19c
|
|||
|
a4ca6023d1
|
|||
|
5ca15bc33f
|
|||
|
6325a32c85
|
|||
|
b50709b7c4
|
|||
|
03e3ebd748
|
|||
|
fa409cb8fb
|
|||
|
db380464a2
|
|||
|
7f91ab754c
|
|||
|
c949094bc8
|
|||
|
6289dbe32e
|
|||
|
b01fc9ff0d
|
|||
|
ffd058dc45
|
|||
|
ef7d1a0f5e
|
|||
|
b7493ddbaf
|
|||
|
c3293ec3ac
|
|||
|
23ff184688
|
|||
|
13b3d7a839
|
|||
|
d2b2bdf2b3
|
|||
|
c551e7220a
|
|||
|
968236e4bb
|
|||
|
6d00283fe2
|
|||
|
a2c3521c48
|
|||
|
0a824f10c8
|
|||
|
8bb26740b0
|
|||
|
0d053e9a7d
|
|||
|
ec3c355ac4
|
|||
|
2a010a777e
|
|||
|
12064196d2
|
@@ -33,8 +33,9 @@ default += .dbs/map.fmt
|
|||||||
echo '*' > $@.gitignore
|
echo '*' > $@.gitignore
|
||||||
|
|
||||||
include cmd.mk
|
include cmd.mk
|
||||||
|
include pub.mk
|
||||||
|
|
||||||
.dbs/head.rec: | .dbs/ $(lists)
|
.dbs/head.rec: | .dbs/
|
||||||
printf '%s\n' '%rec: guide' > $@
|
printf '%s\n' '%rec: guide' > $@
|
||||||
printf '%s\n' '%key: path' >> $@
|
printf '%s\n' '%key: path' >> $@
|
||||||
printf '%s\n' '%type: requires rec guide' >> $@
|
printf '%s\n' '%type: requires rec guide' >> $@
|
||||||
@@ -58,6 +59,7 @@ include cmd.mk
|
|||||||
sed '1,/^---$$/d' $$entry | sed 's/^.*/+ &/' ;\
|
sed '1,/^---$$/d' $$entry | sed 's/^.*/+ &/' ;\
|
||||||
echo '' ;\
|
echo '' ;\
|
||||||
done >> $@
|
done >> $@
|
||||||
|
recfix $@
|
||||||
|
|
||||||
.dbs/requires.rec: .dbs/new.rec
|
.dbs/requires.rec: .dbs/new.rec
|
||||||
recinf -d $< > $@
|
recinf -d $< > $@
|
||||||
@@ -100,7 +102,7 @@ map: .dbs/requires.rec .dbs/map.fmt ## Show knowledge dependency map
|
|||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean: ## Remove all generated files
|
clean: ## Remove all generated files
|
||||||
$(RM) -r $(default) .dbs/
|
$(RM) -r $(default) .dbs/ .publish/
|
||||||
|
|
||||||
.PHONY: article
|
.PHONY: article
|
||||||
article: */ */*/ ## Write a new article
|
article: */ */*/ ## Write a new article
|
||||||
@@ -109,7 +111,9 @@ article: */ */*/ ## Write a new article
|
|||||||
&& filename="$$(echo "$$name" \
|
&& filename="$$(echo "$$name" \
|
||||||
| cut -d: -f1 \
|
| cut -d: -f1 \
|
||||||
| tr '[A-Z ]' '[a-z_]' | tr -cd '[:alpha:]_' )" \
|
| tr '[A-Z ]' '[a-z_]' | tr -cd '[:alpha:]_' )" \
|
||||||
&& $(MAKE) -e TITLE="$$name" "$$category"/"$$filename.md"
|
&& $(MAKE) -e TITLE="$$name" "$$category""$$filename.md"
|
||||||
|
|
||||||
|
default += $(lists) $(publish)
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: $(default) ## All file targets
|
all: $(default) ## All file targets
|
||||||
|
|||||||
+2
-1
@@ -3,6 +3,7 @@ title: profanity
|
|||||||
tags:
|
tags:
|
||||||
- chat
|
- chat
|
||||||
- omemo
|
- omemo
|
||||||
|
- TUI
|
||||||
---
|
---
|
||||||
|
|
||||||
# Setup (Commands)
|
# Setup (Commands)
|
||||||
@@ -44,7 +45,7 @@ Check your `~/.config/profanity/profrc` for how to data's saved.
|
|||||||
To automatically sign in, add your password to [pass](data/pass.md).
|
To automatically sign in, add your password to [pass](data/pass.md).
|
||||||
|
|
||||||
```
|
```
|
||||||
/account set ${name}@${host} eval_password pass *xmpp*
|
/account set ${name}@${host} eval_password "pass ${account}"
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ title: profanity automation
|
|||||||
tags:
|
tags:
|
||||||
- chat
|
- chat
|
||||||
- omemo
|
- omemo
|
||||||
|
- TUI
|
||||||
requires:
|
requires:
|
||||||
- chat/profanity.md
|
- chat/profanity.md
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -1,30 +1,6 @@
|
|||||||
|
|
||||||
cmds != recsel command.rec -t command -G bin -CP bin | sort -u
|
|
||||||
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,bin | \
|
|
||||||
sed 's/.*/- &/'
|
|
||||||
|
|
||||||
list_commands = recsel -t $(basename $<) $< -e 'bin = "$(1)"' | \
|
|
||||||
recfmt -f lists.fmt
|
|
||||||
|
|
||||||
$(lists): lists/%.md: command.rec | lists/
|
|
||||||
@printf '%s\n' '---' > $@
|
|
||||||
@$(call get_title,$(basename $(notdir $@))) >> $@
|
|
||||||
@printf '%s\n' 'tags: ' >> $@
|
|
||||||
@$(call get_tags,$(basename $(notdir $@))) >> $@
|
|
||||||
@printf '%s\n' '---' >> $@
|
|
||||||
@$(call list_commands,$(basename $(notdir $@))) >> $@
|
|
||||||
|
|
||||||
.PHONY: cmd
|
|
||||||
cmd: $(lists) ## Big lists of commands
|
|
||||||
|
|
||||||
.PHONY: function
|
.PHONY: function
|
||||||
function: ## Output a search function for .bashrc
|
function: | db.rec ## Output a search function for .bashrc
|
||||||
${MAKE} --silent --touch query
|
${MAKE} --silent --touch query
|
||||||
printf '%s\n' 'lk(){'
|
printf '%s\n' 'lk(){'
|
||||||
${MAKE} --silent --dry-run query | sed 's/^/\t/'
|
${MAKE} --silent --dry-run query | sed 's/^/\t/'
|
||||||
|
|||||||
+408
-322
@@ -1,8 +1,54 @@
|
|||||||
%rec: command
|
%rec: command
|
||||||
%doc: shell command examples
|
%doc: shell command examples
|
||||||
%type: aim line
|
%type: aim,bin line
|
||||||
%allowed: aim cmd bin tag note shell
|
%allowed: aim cmd bin tag note shell
|
||||||
%unique: shell
|
%unique: shell
|
||||||
|
%sort: shell bin
|
||||||
|
|
||||||
|
aim: Roll a die
|
||||||
|
cmd: echo $(( RANDOM % 6+1 ))
|
||||||
|
shell: bash
|
||||||
|
tag: random
|
||||||
|
|
||||||
|
aim: Decode a URL with function
|
||||||
|
cmd: urldecode() { echo -e "${@//%/\\x}"; }
|
||||||
|
+ urldecode "${magnet}"
|
||||||
|
tag: web
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
aim: Find your public IP address
|
||||||
|
cmd: dig +short myip.opendns.com @resolver$((RANDOM % 4 + 1)).opendns.com
|
||||||
|
shell: bash
|
||||||
|
bin: dig
|
||||||
|
tag: ip
|
||||||
|
tag: network
|
||||||
|
|
||||||
|
aim: Turn markdown into a man page
|
||||||
|
cmd: man <(lowdown -stman ${file}.md)
|
||||||
|
cmd: top_title="Bugs in netcat"
|
||||||
|
+ someplace=LK
|
||||||
|
+ vol=Security
|
||||||
|
+ sec=6
|
||||||
|
+ lowdown -m manheader="${top_title}" -m source="${someplace}" -m volume="${vol}" -m section=${sec} -stman ${file}.md > ${file}.${sec}
|
||||||
|
+ man ./${file}.${sec}
|
||||||
|
shell: bash
|
||||||
|
bin: lowdown
|
||||||
|
bin: groff
|
||||||
|
bin: man
|
||||||
|
tag: markdown
|
||||||
|
|
||||||
|
aim: Rotate a video
|
||||||
|
cmd: ffmpeg -i "${input}" -vf "transpose=1" "${out.mov}"
|
||||||
|
note:
|
||||||
|
+ | No. | Degrees | Flip |
|
||||||
|
+ |:---:|:-------:|:---------------------------------------------|
|
||||||
|
+ | 0 | 90 | Counterclockwise and verfical flip (default) |
|
||||||
|
+ | 1 | 90 | Clockwise |
|
||||||
|
+ | 2 | 90 | CounterClockwise |
|
||||||
|
+ | 3 | 90 | Clockwise and vertical flip |
|
||||||
|
tag: vision
|
||||||
|
tag: video
|
||||||
|
shell: sh
|
||||||
|
|
||||||
aim: Put output into columns
|
aim: Put output into columns
|
||||||
cmd: ip a | grep inet | column -ts' '
|
cmd: ip a | grep inet | column -ts' '
|
||||||
@@ -37,294 +83,21 @@ bin: column
|
|||||||
tag: format
|
tag: format
|
||||||
tag: json
|
tag: json
|
||||||
|
|
||||||
aim: Make a QR Code image
|
aim: Request a definition from the terminal.
|
||||||
cmd: qrencode 'https://play.google.com/store/apps/details?id=org.briarproject.briar.android' -o "${file}".png
|
cmd: word='abderian'
|
||||||
shell: sh
|
+ curl -s dict://dict.org/define:${word}:
|
||||||
bin: qrencode
|
cmd: function wotsa(){
|
||||||
tag: qr
|
+ def="$(curl -s dict://dict.org/define:${1// /+}: | grep -vP '^\d\d\d ')"
|
||||||
|
+ if [ "$def" = "" ]; then
|
||||||
aim: Make a QR Coded message in the terminal
|
+ echo no definition
|
||||||
cmd: qrencode -t ansi "Hello World"
|
+ else
|
||||||
shell: sh
|
+ echo "$def" | $PAGER
|
||||||
bin: qrencode
|
+ fi
|
||||||
tag: qr
|
+ }
|
||||||
|
bin: curl
|
||||||
aim: Read a QR Code image
|
|
||||||
cmd: zbarimg ${file}
|
|
||||||
shell: sh
|
|
||||||
bin: qrencode
|
|
||||||
tag: qr
|
|
||||||
|
|
||||||
aim: Show wifi QR code (only with Network Manager)
|
|
||||||
cmd: nmcli device wifi show-password
|
|
||||||
shell: sh
|
|
||||||
bin: qrencode
|
|
||||||
bin: nmcli
|
|
||||||
tag: qr
|
|
||||||
tag: wifi
|
|
||||||
|
|
||||||
aim: Combine many recfiles of different types into one
|
|
||||||
cmd: sed '1i\ ' *.rec > all.rec
|
|
||||||
shell: sh
|
|
||||||
bin: sed
|
|
||||||
tag: recfiles
|
|
||||||
tag: database
|
|
||||||
|
|
||||||
aim: Combine many recfiles of the same type into one
|
|
||||||
cmd: recinf -d -t ${type} ${one}.rec > ${all}.rec
|
|
||||||
+ sed '/^%/d' ${one}.rec ${two}.rec > all.rec
|
|
||||||
note: The strange syntax used by `sed` only makes sense after using [ed](writing/ed.md)
|
|
||||||
shell: sh
|
|
||||||
bin: sed
|
|
||||||
bin: recinf
|
|
||||||
tag: recfiles
|
|
||||||
tag: database
|
|
||||||
|
|
||||||
aim: Roll a die
|
|
||||||
cmd: echo $(( RANDOM % 6+1 ))
|
|
||||||
shell: bash
|
|
||||||
tag: random
|
|
||||||
|
|
||||||
aim: Remotely edit a file with vim
|
|
||||||
cmd: vim scp://${server}/~/${file}
|
|
||||||
cmd: vim scp://${user}@${server}:${port}//${path}/${file}
|
|
||||||
shell: sh
|
|
||||||
bin: vim
|
|
||||||
bin: scp
|
|
||||||
tag: network
|
|
||||||
|
|
||||||
aim: Find and replace across all files open in vim
|
|
||||||
cmd: :bufdo! %s/${pattern}/${replacement}/g
|
|
||||||
shell: sh
|
|
||||||
bin: vim
|
|
||||||
tag: writing
|
tag: writing
|
||||||
tag: replace
|
|
||||||
|
|
||||||
aim: Find and replace words, but confirm each replacement
|
|
||||||
cmd: vim -c "%s/${pattern}/${replacement}/gc" -c 'wq' ${file}
|
|
||||||
shell: sh
|
|
||||||
bin: vim
|
|
||||||
tag: replace
|
|
||||||
tag: substitution
|
|
||||||
tag: TUI
|
|
||||||
tag: writing
|
|
||||||
|
|
||||||
aim: Hard reset ntp service
|
|
||||||
cmd: sudo ntpd -q -g -x -n
|
|
||||||
bin: ntpd
|
|
||||||
tag: time
|
|
||||||
tag: system
|
|
||||||
|
|
||||||
aim: Check a service
|
|
||||||
cmd: sudo systemctl status mpd
|
|
||||||
shell: sh
|
|
||||||
bin: systemd
|
|
||||||
tag: system
|
|
||||||
tag: service
|
|
||||||
|
|
||||||
aim: Recognize service changes
|
|
||||||
cmd: sudo systemctl daemon-reload
|
|
||||||
shell: sh
|
|
||||||
bin: systemd
|
|
||||||
tag: system
|
|
||||||
tag: service
|
|
||||||
|
|
||||||
aim: Start a service (it stops when the computer shuts down)
|
|
||||||
cmd: sudo systemctl taskd.service start
|
|
||||||
+ sudo systemctl daemon-reload
|
|
||||||
shell: sh
|
|
||||||
bin: systemd
|
|
||||||
tag: system
|
|
||||||
tag: service
|
|
||||||
|
|
||||||
aim: Find out why the computer takes so long to start
|
|
||||||
cmd: sudo systemd-analyze
|
|
||||||
+ sudo systemd-analyze blame
|
|
||||||
shell: sh
|
|
||||||
bin: systemd
|
|
||||||
tag: system
|
|
||||||
tag: boot
|
|
||||||
|
|
||||||
aim: See what the computer is doing
|
|
||||||
cmd: journalctl -f
|
|
||||||
shell: sh
|
|
||||||
bin: journalctl
|
|
||||||
tag: system
|
|
||||||
|
|
||||||
aim: Check your own user services:
|
|
||||||
cmd: journalctl -f
|
|
||||||
shell: sh
|
|
||||||
bin: journalctl
|
|
||||||
tag: system
|
|
||||||
|
|
||||||
aim: Follow the `ssh` daemon service
|
|
||||||
cmd: journalctl -f -u sshd
|
|
||||||
shell: sh
|
|
||||||
bin: journalctl
|
|
||||||
tag: system
|
|
||||||
|
|
||||||
aim: Find errors since a date
|
|
||||||
cmd: date=2027-01-01
|
|
||||||
+ journalctl --since=${date} --grep="EXT4-fs error"
|
|
||||||
shell: sh
|
|
||||||
bin: journalctl
|
|
||||||
tag: system
|
|
||||||
|
|
||||||
aim: Limit the journal's size to 2 gigabytes
|
|
||||||
cmd: journalctl --vacuum-size=2G
|
|
||||||
shell: sh
|
|
||||||
bin: journalctl
|
|
||||||
tag: system
|
|
||||||
|
|
||||||
aim: Log the fact that you've installed your own `dnsmasq` on your system to `journalctl`, so that you can determine why your system's broken later
|
|
||||||
cmd: logger "Installed new dnsmasq"
|
|
||||||
+ sudo journalctl -f
|
|
||||||
shell: sh
|
|
||||||
bin: journalctl
|
|
||||||
tag: system
|
|
||||||
|
|
||||||
aim: Convert markdown table to csv
|
|
||||||
cmd: mlr --imarkdown --ocsv cat ${file}.md
|
|
||||||
bin: mlr
|
|
||||||
tag: csv
|
|
||||||
tag: markdown
|
|
||||||
tag: data
|
|
||||||
|
|
||||||
aim: Convert a csv file to markdown
|
|
||||||
cmd: mlr --icsv --omd cat ${file}.csv
|
|
||||||
bin: mlr
|
|
||||||
tag: csv
|
|
||||||
tag: markdown
|
|
||||||
|
|
||||||
aim: Quickly find and open run-command files
|
|
||||||
cmd: alias rrc='$PAGER "$(find . -maxdepth 2 -name "*rc" | fzf)"'
|
|
||||||
bin: fzf
|
|
||||||
bin: find
|
|
||||||
tag: comfy
|
tag: comfy
|
||||||
|
tag: dict
|
||||||
aim: Quickly hunt and kill processes
|
|
||||||
cmd: kill $(pgrep less | fzf -m --preview='ps {}')
|
|
||||||
note: Select many with shift/tab.
|
|
||||||
bin: fzf
|
|
||||||
tag: comfy
|
|
||||||
|
|
||||||
aim: Search for a short word
|
|
||||||
cmd: grep "\b${word}\b" ${file}
|
|
||||||
bin: grep
|
|
||||||
tag: search
|
|
||||||
|
|
||||||
aim: Extract words in quotes
|
|
||||||
cmd: grep -o "\b${word}\b" ${file}
|
|
||||||
bin: grep
|
|
||||||
tag: search
|
|
||||||
|
|
||||||
aim: Reformat variable for shell input
|
|
||||||
cmd: printf "%q\n" "${variable}"
|
|
||||||
bin: printf
|
|
||||||
tag: xargs
|
|
||||||
tag: stdout
|
|
||||||
|
|
||||||
aim: Find your public IP address
|
|
||||||
cmd: dig +short myip.opendns.com @resolver$((RANDOM % 4 + 1)).opendns.com
|
|
||||||
shell: bash
|
|
||||||
bin: dig
|
|
||||||
tag: ip
|
|
||||||
tag: network
|
|
||||||
|
|
||||||
aim: Turn markdown into a man page
|
|
||||||
cmd: man <(lowdown -stman ${file}.md)
|
|
||||||
cmd: top_title="Bugs in netcat"
|
|
||||||
+ someplace=LK
|
|
||||||
+ vol=Security
|
|
||||||
+ sec=6
|
|
||||||
+ lowdown -m manheader="${top_title}" -m source="${someplace}" -m volume="${vol}" -m section=${sec} -stman ${file}.md > ${file}.${sec}
|
|
||||||
+ man ./${file}.${sec}
|
|
||||||
shell: bash
|
|
||||||
bin: lowdown
|
|
||||||
bin: groff
|
|
||||||
bin: man
|
|
||||||
tag: markdown
|
|
||||||
|
|
||||||
aim: Convert jpg to png
|
|
||||||
cmd: magick ${input}.jpg ${output}.png
|
|
||||||
bin: magick
|
|
||||||
tag: vision
|
|
||||||
|
|
||||||
aim: Reduce jpg size by reducing quality
|
|
||||||
cmd: quality=70
|
|
||||||
+ magick ${input}.jpg -quality ${quality} ${output}.jpg
|
|
||||||
cmd: size=50
|
|
||||||
+ magick -resize ${size}% ${input}.jpg ${output}.jpg
|
|
||||||
bin: magick
|
|
||||||
tag: vision
|
|
||||||
|
|
||||||
aim: Reduce png size
|
|
||||||
cmd: magick ${input}.png png8:${output}.png
|
|
||||||
bin: magick
|
|
||||||
tag: vision
|
|
||||||
|
|
||||||
aim: Invert jpg colours
|
|
||||||
cmd: magick ${input}.jpg ${output}.jpg -negate
|
|
||||||
bin: magick
|
|
||||||
tag: vision
|
|
||||||
|
|
||||||
aim: Make jpg smaller
|
|
||||||
cmd: magick ${input}.jpg -resize 25% ${output}.jpg
|
|
||||||
bin: magick
|
|
||||||
tag: vision
|
|
||||||
|
|
||||||
aim: Trim images to border
|
|
||||||
cmd: magick -trim ${image}.png ${output}.png
|
|
||||||
bin: magick
|
|
||||||
tag: vision
|
|
||||||
|
|
||||||
aim: Make the white of an image transparent
|
|
||||||
cmd: magick -transparent white -fuzz 10% ${input}.png ${output}.png
|
|
||||||
bin: magick
|
|
||||||
tag: vision
|
|
||||||
note: The 'fuzz' option tells the computer that 'close to white' is fine. You might want to use 20% or higher fuzz.
|
|
||||||
|
|
||||||
aim: Give transparrent image a dropshadow
|
|
||||||
cmd: magick ${input}.png \( +clone -background black -shadow 50x8+0+5 \) +swap -background none -layers merge +repage ${output}.png
|
|
||||||
bin: magick
|
|
||||||
tag: vision
|
|
||||||
|
|
||||||
aim: Convert every jpg in directory to png
|
|
||||||
cmd: mogrify -format png *.jpg
|
|
||||||
bin: magick
|
|
||||||
tag: vision
|
|
||||||
|
|
||||||
aim: Convert from jpg to svg
|
|
||||||
cmd: magick -flatten ${input}.jpg ${output}.ppm
|
|
||||||
+ potrace -s ${output}.ppm -o ${svgout}.svg
|
|
||||||
bin: magick
|
|
||||||
tag: vision
|
|
||||||
|
|
||||||
aim: Make an image showing day of the week
|
|
||||||
cmd: magick -list font
|
|
||||||
+ font="$(magick -list font | grep -oP 'Font: \K.*' | head -1)"
|
|
||||||
+
|
|
||||||
+ magick -fill blue -font "${font}" -gravity center -pointsize 79 label:$(date +%A) day.png
|
|
||||||
bin: magick
|
|
||||||
tag: vision
|
|
||||||
|
|
||||||
aim: Make a meme
|
|
||||||
cmd: magick ${input} -font impact -fill white -pointsize 84 -stroke black -strokewidth 3 -gravity north -annotate +0+20 'TOP MEME TEXT' -gravity south -annotate +0+20 'BOTTOM MEME TEXT' ${output}
|
|
||||||
bin: magick
|
|
||||||
tag: vision
|
|
||||||
tag: memes
|
|
||||||
|
|
||||||
aim: Rotate a video
|
|
||||||
cmd: ffmpeg -i "${input}" -vf "transpose=1" "${out.mov}"
|
|
||||||
note:
|
|
||||||
+ | No. | Degrees | Flip |
|
|
||||||
+ |:---:|:-------:|:---------------------------------------|
|
|
||||||
+ | 0 | 90 Counterclockwise and verfical flip (default) |
|
|
||||||
+ | 1 | 90 Clockwise |
|
|
||||||
+ | 2 | 90 CounterClockwise |
|
|
||||||
+ | 3 | 90Clockwise and vertical flip |
|
|
||||||
tag: vision
|
|
||||||
tag: video
|
|
||||||
shell: sh
|
shell: sh
|
||||||
|
|
||||||
aim: Translate a media file to a new type
|
aim: Translate a media file to a new type
|
||||||
@@ -413,48 +186,23 @@ bin: ffmpeg
|
|||||||
tag: vision
|
tag: vision
|
||||||
shell: sh
|
shell: sh
|
||||||
|
|
||||||
aim: Convert a web page to markdown
|
aim: Quickly find and open run-command files
|
||||||
cmd: curl -sL "${url}" | html2markdown > "${file}}".md
|
cmd: alias rrc='$PAGER "$(find . -maxdepth 2 -name "*rc" | fzf)"'
|
||||||
cmd: curl -sL "${url}" | html2text > "${file}}".md
|
|
||||||
note: The `[html2markdown](https://github.com/JohannesKaufmann/html-to-markdown)` and `html2md` programs works better than any other.
|
|
||||||
bin: html2markdown
|
|
||||||
bin: curl
|
|
||||||
tag: writing
|
|
||||||
tag: web
|
|
||||||
shell: sh
|
shell: sh
|
||||||
|
bin: fzf
|
||||||
aim: Decode a URL with function
|
bin: find
|
||||||
cmd: urldecode() { echo -e "${@//%/\\x}"; }
|
|
||||||
+ urldecode "${magnet}"
|
|
||||||
tag: web
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
aim: Choose which parts to commit with git
|
|
||||||
cmd: git commit -p
|
|
||||||
note: Use `P` to see big changes which cannot fit on the screen.
|
|
||||||
tag: comfy
|
tag: comfy
|
||||||
bin: git
|
|
||||||
shell: sh
|
|
||||||
|
|
||||||
aim: Request a definition from the terminal.
|
aim: Quickly hunt and kill processes
|
||||||
cmd: word='abderian'
|
cmd: kill $(pgrep less | fzf -m --preview='ps {}')
|
||||||
+ curl -s dict://dict.org/define:${word}:
|
note: Select many with shift/tab.
|
||||||
cmd: function wotsa(){
|
|
||||||
+ def="$(curl -s dict://dict.org/define:${1// /+}: | grep -vP '^\d\d\d ')"
|
|
||||||
+ if [ "$def" = "" ]; then
|
|
||||||
+ echo no definition
|
|
||||||
+ else
|
|
||||||
+ echo "$def" | $PAGER
|
|
||||||
+ fi
|
|
||||||
+ }
|
|
||||||
bin: curl
|
|
||||||
tag: writing
|
|
||||||
tag: comfy
|
|
||||||
tag: dict
|
|
||||||
shell: sh
|
shell: sh
|
||||||
|
bin: fzf
|
||||||
|
tag: comfy
|
||||||
|
|
||||||
aim: Email a pull request which points to your git server
|
aim: Email a pull request which points to your git server
|
||||||
tag: git
|
tag: git
|
||||||
|
shell: sh
|
||||||
bin: git
|
bin: git
|
||||||
tag: email
|
tag: email
|
||||||
tag: pr
|
tag: pr
|
||||||
@@ -465,6 +213,13 @@ cmd: repo=ssh://soft.dmz.rs:2222/mkdots/
|
|||||||
note: You can note where your branch diverged from theirs with a commit hash,
|
note: You can note where your branch diverged from theirs with a commit hash,
|
||||||
+ or a relative position, like `HEAD^^` (e.g. 'two commits before your latest').
|
+ or a relative position, like `HEAD^^` (e.g. 'two commits before your latest').
|
||||||
|
|
||||||
|
aim: Choose which parts to commit with git
|
||||||
|
cmd: git commit -p
|
||||||
|
note: Use `P` to see big changes which cannot fit on the screen.
|
||||||
|
tag: comfy
|
||||||
|
bin: git
|
||||||
|
shell: sh
|
||||||
|
|
||||||
aim: Clean up a bloated git repo
|
aim: Clean up a bloated git repo
|
||||||
cmd: git fsck --full
|
cmd: git fsck --full
|
||||||
+ git gc --prune=now --aggressive
|
+ git gc --prune=now --aggressive
|
||||||
@@ -473,3 +228,334 @@ bin: git
|
|||||||
tag: maintenance
|
tag: maintenance
|
||||||
shell: sh
|
shell: sh
|
||||||
|
|
||||||
|
aim: Search for a short word
|
||||||
|
cmd: grep "\b${word}\b" ${file}
|
||||||
|
shell: sh
|
||||||
|
bin: grep
|
||||||
|
tag: search
|
||||||
|
|
||||||
|
aim: Extract words in quotes
|
||||||
|
cmd: grep -o "\b${word}\b" ${file}
|
||||||
|
shell: sh
|
||||||
|
bin: grep
|
||||||
|
tag: search
|
||||||
|
|
||||||
|
aim: Convert a web page to markdown
|
||||||
|
cmd: curl -sL "${url}" | html2markdown > "${file}}".md
|
||||||
|
cmd: curl -sL "${url}" | html2text > "${file}}".md
|
||||||
|
note: The `[html2markdown](https://github.com/JohannesKaufmann/html-to-markdown)` and `html2md` programs works better than any other.
|
||||||
|
bin: html2markdown
|
||||||
|
bin: curl
|
||||||
|
tag: writing
|
||||||
|
tag: web
|
||||||
|
shell: sh
|
||||||
|
|
||||||
|
aim: Run commands in background
|
||||||
|
cmd: ls -Rilt ~ &
|
||||||
|
+ jobs
|
||||||
|
+ find ~/.cache/ -type d -exec du '{}' -h ';' | sort -h &
|
||||||
|
+ jobs
|
||||||
|
shell: sh
|
||||||
|
bin: jobs
|
||||||
|
tag: shell
|
||||||
|
tag: comfy
|
||||||
|
|
||||||
|
aim: Stop background command having output
|
||||||
|
cmd: disown
|
||||||
|
note: The command will continue as it was. You can see it with `top`.
|
||||||
|
shell: sh
|
||||||
|
bin: jobs
|
||||||
|
tag: shell
|
||||||
|
tag: comfy
|
||||||
|
|
||||||
|
aim: See what the computer is doing
|
||||||
|
cmd: journalctl -f
|
||||||
|
shell: sh
|
||||||
|
bin: journalctl
|
||||||
|
tag: system
|
||||||
|
|
||||||
|
aim: Check your own user services:
|
||||||
|
cmd: journalctl -f
|
||||||
|
shell: sh
|
||||||
|
bin: journalctl
|
||||||
|
tag: system
|
||||||
|
|
||||||
|
aim: Follow the `ssh` daemon service
|
||||||
|
cmd: journalctl -f -u sshd
|
||||||
|
shell: sh
|
||||||
|
bin: journalctl
|
||||||
|
tag: system
|
||||||
|
|
||||||
|
aim: Find errors since a date
|
||||||
|
cmd: date=2027-01-01
|
||||||
|
+ journalctl --since=${date} --grep="EXT4-fs error"
|
||||||
|
shell: sh
|
||||||
|
bin: journalctl
|
||||||
|
tag: system
|
||||||
|
|
||||||
|
aim: Limit the systemd's journal size to 2 gigabytes
|
||||||
|
cmd: journalctl --vacuum-size=2G
|
||||||
|
+ journalctl --disk-usage
|
||||||
|
shell: sh
|
||||||
|
bin: journalctl
|
||||||
|
tag: system
|
||||||
|
tag: logs
|
||||||
|
|
||||||
|
aim: Log the fact that you've installed your own `dnsmasq` on your system to `journalctl`, so that you can determine why your system's broken later
|
||||||
|
cmd: logger "Installed new dnsmasq"
|
||||||
|
+ sudo journalctl -f
|
||||||
|
shell: sh
|
||||||
|
bin: journalctl
|
||||||
|
bin: logger
|
||||||
|
tag: system
|
||||||
|
tag: logs
|
||||||
|
|
||||||
|
aim: Convert jpg to png
|
||||||
|
cmd: magick ${input}.jpg ${output}.png
|
||||||
|
shell: sh
|
||||||
|
bin: magick
|
||||||
|
tag: vision
|
||||||
|
|
||||||
|
aim: Reduce jpg size by reducing quality
|
||||||
|
cmd: quality=70
|
||||||
|
+ magick ${input}.jpg -quality ${quality} ${output}.jpg
|
||||||
|
cmd: size=50
|
||||||
|
+ magick -resize ${size}% ${input}.jpg ${output}.jpg
|
||||||
|
shell: sh
|
||||||
|
bin: magick
|
||||||
|
tag: vision
|
||||||
|
|
||||||
|
aim: Reduce png size
|
||||||
|
cmd: magick ${input}.png png8:${output}.png
|
||||||
|
shell: sh
|
||||||
|
bin: magick
|
||||||
|
tag: vision
|
||||||
|
|
||||||
|
aim: Invert jpg colours
|
||||||
|
cmd: magick ${input}.jpg ${output}.jpg -negate
|
||||||
|
shell: sh
|
||||||
|
bin: magick
|
||||||
|
tag: vision
|
||||||
|
|
||||||
|
aim: Make jpg smaller
|
||||||
|
cmd: magick ${input}.jpg -resize 25% ${output}.jpg
|
||||||
|
shell: sh
|
||||||
|
bin: magick
|
||||||
|
tag: vision
|
||||||
|
|
||||||
|
aim: Trim images to border
|
||||||
|
cmd: magick -trim ${image}.png ${output}.png
|
||||||
|
shell: sh
|
||||||
|
bin: magick
|
||||||
|
tag: vision
|
||||||
|
|
||||||
|
aim: Make the white of an image transparent
|
||||||
|
cmd: magick -transparent white -fuzz 10% ${input}.png ${output}.png
|
||||||
|
shell: sh
|
||||||
|
bin: magick
|
||||||
|
tag: vision
|
||||||
|
note: The 'fuzz' option tells the computer that 'close to white' is fine. You might want to use 20% or higher fuzz.
|
||||||
|
|
||||||
|
aim: Give transparrent image a dropshadow
|
||||||
|
cmd: magick ${input}.png \( +clone -background black -shadow 50x8+0+5 \) +swap -background none -layers merge +repage ${output}.png
|
||||||
|
shell: sh
|
||||||
|
bin: magick
|
||||||
|
tag: vision
|
||||||
|
|
||||||
|
aim: Convert every jpg in directory to png
|
||||||
|
cmd: mogrify -format png *.jpg
|
||||||
|
shell: sh
|
||||||
|
bin: magick
|
||||||
|
tag: vision
|
||||||
|
|
||||||
|
aim: Convert from jpg to svg
|
||||||
|
cmd: magick -flatten ${input}.jpg ${output}.ppm
|
||||||
|
+ potrace -s ${output}.ppm -o ${svgout}.svg
|
||||||
|
shell: sh
|
||||||
|
bin: magick
|
||||||
|
tag: vision
|
||||||
|
|
||||||
|
aim: Make an image showing day of the week
|
||||||
|
cmd: magick -list font
|
||||||
|
+ font="$(magick -list font | grep -oP 'Font: \K.*' | head -1)"
|
||||||
|
+
|
||||||
|
+ magick -fill blue -font "${font}" -gravity center -pointsize 79 label:$(date +%A) day.png
|
||||||
|
shell: sh
|
||||||
|
bin: magick
|
||||||
|
tag: vision
|
||||||
|
|
||||||
|
aim: Make a meme
|
||||||
|
cmd: magick ${input} -font impact -fill white -pointsize 84 -stroke black -strokewidth 3 -gravity north -annotate +0+20 'TOP MEME TEXT' -gravity south -annotate +0+20 'BOTTOM MEME TEXT' ${output}
|
||||||
|
shell: sh
|
||||||
|
bin: magick
|
||||||
|
tag: vision
|
||||||
|
tag: memes
|
||||||
|
|
||||||
|
aim: Convert markdown table to csv
|
||||||
|
cmd: mlr --imarkdown --ocsv cat ${file}.md
|
||||||
|
shell: sh
|
||||||
|
bin: mlr
|
||||||
|
tag: csv
|
||||||
|
tag: markdown
|
||||||
|
tag: data
|
||||||
|
|
||||||
|
aim: Convert a csv file to markdown
|
||||||
|
cmd: mlr --icsv --omd cat ${file}.csv
|
||||||
|
shell: sh
|
||||||
|
bin: mlr
|
||||||
|
tag: csv
|
||||||
|
tag: markdown
|
||||||
|
|
||||||
|
aim: Hard reset ntp service
|
||||||
|
cmd: sudo ntpd -q -g -x -n
|
||||||
|
shell: sh
|
||||||
|
bin: ntpd
|
||||||
|
tag: time
|
||||||
|
tag: system
|
||||||
|
|
||||||
|
aim: Uncompress a PDF
|
||||||
|
cmd: pdftk ${input}.pdf output ${output}.pdf uncompress
|
||||||
|
shell: sh
|
||||||
|
bin: pdftk
|
||||||
|
tag: pdf
|
||||||
|
tag: compression
|
||||||
|
|
||||||
|
aim: Reformat text for shell input
|
||||||
|
cmd: printf "%q\n" "${text}"
|
||||||
|
shell: sh
|
||||||
|
bin: printf
|
||||||
|
tag: xargs
|
||||||
|
tag: stdout
|
||||||
|
|
||||||
|
aim: Make a QR Code image
|
||||||
|
cmd: qrencode 'https://play.google.com/store/apps/details?id=org.briarproject.briar.android' -o "${file}".png
|
||||||
|
shell: sh
|
||||||
|
bin: qrencode
|
||||||
|
tag: qr
|
||||||
|
|
||||||
|
aim: Make a QR Coded message in the terminal
|
||||||
|
cmd: qrencode -t ansi "Hello World"
|
||||||
|
shell: sh
|
||||||
|
bin: qrencode
|
||||||
|
tag: qr
|
||||||
|
|
||||||
|
aim: Read a QR Code image
|
||||||
|
cmd: zbarimg ${file}
|
||||||
|
shell: sh
|
||||||
|
bin: qrencode
|
||||||
|
tag: qr
|
||||||
|
|
||||||
|
aim: Show wifi QR code (only with Network Manager)
|
||||||
|
cmd: nmcli device wifi show-password
|
||||||
|
shell: sh
|
||||||
|
bin: qrencode
|
||||||
|
bin: nmcli
|
||||||
|
tag: qr
|
||||||
|
tag: wifi
|
||||||
|
|
||||||
|
aim: Combine many recfiles of different types into one
|
||||||
|
cmd: sed '1i\ ' *.rec > all.rec
|
||||||
|
shell: sh
|
||||||
|
bin: sed
|
||||||
|
tag: recfiles
|
||||||
|
tag: database
|
||||||
|
|
||||||
|
aim: Combine many recfiles of the same type into one
|
||||||
|
cmd: recinf -d -t ${type} ${one}.rec > ${all}.rec
|
||||||
|
+ sed '/^%/d' ${one}.rec ${two}.rec > all.rec
|
||||||
|
note: The strange syntax used by `sed` only makes sense after using [ed](writing/ed.md)
|
||||||
|
shell: sh
|
||||||
|
bin: sed
|
||||||
|
bin: recinf
|
||||||
|
tag: recfiles
|
||||||
|
tag: database
|
||||||
|
|
||||||
|
aim: Get back terminal after ssh freezes remote machine
|
||||||
|
cmd: <Return>~.
|
||||||
|
shell: sh
|
||||||
|
bin: ssh
|
||||||
|
tag: system
|
||||||
|
tag: comfy
|
||||||
|
|
||||||
|
aim: Check a service
|
||||||
|
cmd: sudo systemctl status mpd
|
||||||
|
shell: sh
|
||||||
|
bin: systemd
|
||||||
|
tag: system
|
||||||
|
tag: service
|
||||||
|
|
||||||
|
aim: Recognize service changes
|
||||||
|
cmd: sudo systemctl daemon-reload
|
||||||
|
shell: sh
|
||||||
|
bin: systemd
|
||||||
|
tag: system
|
||||||
|
tag: service
|
||||||
|
|
||||||
|
aim: Start a service (it stops when the computer shuts down)
|
||||||
|
cmd: sudo systemctl taskd.service start
|
||||||
|
+ sudo systemctl daemon-reload
|
||||||
|
shell: sh
|
||||||
|
bin: systemd
|
||||||
|
tag: system
|
||||||
|
tag: service
|
||||||
|
|
||||||
|
aim: Find out why the computer takes so long to start
|
||||||
|
cmd: sudo systemd-analyze
|
||||||
|
+ sudo systemd-analyze blame
|
||||||
|
shell: sh
|
||||||
|
bin: systemd
|
||||||
|
tag: system
|
||||||
|
tag: boot
|
||||||
|
|
||||||
|
aim: Remotely edit a file with vim
|
||||||
|
cmd: vim scp://${server}/~/${file}
|
||||||
|
cmd: vim scp://${user}@${server}:${port}//${path}/${file}
|
||||||
|
shell: sh
|
||||||
|
bin: vim
|
||||||
|
bin: scp
|
||||||
|
tag: network
|
||||||
|
|
||||||
|
aim: Read info files with vim
|
||||||
|
cmd: info ()
|
||||||
|
+ {
|
||||||
|
+ [ -n "$1" ] && file="${1}" || file="$(ls /usr/share/info/ | sed 's/\.info.gz$//' | fzf )";
|
||||||
|
+ file="$(ls /usr/share/info/"$file"* | fzf -1 )"
|
||||||
|
+ vim "$file"
|
||||||
|
+ }
|
||||||
|
shell: sh
|
||||||
|
bin: vim
|
||||||
|
bin: info
|
||||||
|
tag: documentation
|
||||||
|
|
||||||
|
aim: Find and replace across all files open in vim
|
||||||
|
cmd: :bufdo! %s/${pattern}/${replacement}/g
|
||||||
|
shell: sh
|
||||||
|
bin: vim
|
||||||
|
tag: writing
|
||||||
|
tag: replace
|
||||||
|
|
||||||
|
aim: Find and replace words, but confirm each replacement
|
||||||
|
cmd: vim -c "%s/${pattern}/${replacement}/gc" -c 'wq' ${file}
|
||||||
|
shell: sh
|
||||||
|
bin: vim
|
||||||
|
tag: replace
|
||||||
|
tag: substitution
|
||||||
|
tag: TUI
|
||||||
|
tag: writing
|
||||||
|
|
||||||
|
aim: Edit users in /etc/passwd directly
|
||||||
|
cmd: sudo vipw
|
||||||
|
note: You can't edit passwords without strange cyphers.
|
||||||
|
shell: sh
|
||||||
|
bin: vipw
|
||||||
|
bin: sudo
|
||||||
|
tag: system
|
||||||
|
tag: users
|
||||||
|
|
||||||
|
aim: Edit groups in /etc/group directly
|
||||||
|
cmd: sudo vigr
|
||||||
|
shell: sh
|
||||||
|
bin: vipw
|
||||||
|
bin: sudo
|
||||||
|
tag: system
|
||||||
|
tag: groups
|
||||||
|
|||||||
+20
-20
@@ -16,23 +16,23 @@ Make a database for your boardgames, specifying only one field and value:
|
|||||||
database=games.rec
|
database=games.rec
|
||||||
n=Name
|
n=Name
|
||||||
g=Vojvodina
|
g=Vojvodina
|
||||||
touch $database
|
touch ${database}
|
||||||
recins -f $n --value $g $database
|
recins -f ${n} --value ${g} ${database}
|
||||||
recsel $database
|
recsel ${database}
|
||||||
```
|
```
|
||||||
|
|
||||||
Insert a few more, with the estimated playtime:
|
Insert a few more, with the estimated playtime:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
recins -f Name -v Saboter -f Playtime -v 30 $database
|
recins -f Name -v Saboter -f Playtime -v 30 ${database}
|
||||||
recins -f Name -v Chess -f Playtime -v 30 $database
|
recins -f Name -v Chess -f Playtime -v 30 ${database}
|
||||||
```
|
```
|
||||||
|
|
||||||
View all games, or select one by number:
|
View all games, or select one by number:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
recsel $database
|
recsel ${database}
|
||||||
recsel -n 0 $database
|
recsel -n 0 ${database}
|
||||||
```
|
```
|
||||||
|
|
||||||
Each game should note whether or not you have played it yet, so you can add that field and set the default to `yes`.
|
Each game should note whether or not you have played it yet, so you can add that field and set the default to `yes`.
|
||||||
@@ -40,14 +40,14 @@ Each game should note whether or not you have played it yet, so you can add that
|
|||||||
```sh
|
```sh
|
||||||
f=played
|
f=played
|
||||||
v=yes
|
v=yes
|
||||||
recset -f $f -a $v $database
|
recset -f ${f} -a ${v} ${database}
|
||||||
```
|
```
|
||||||
|
|
||||||
...but the field is wrong, it should have a capital letter:
|
...but the field is wrong, it should have a capital letter:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
new_field=Played
|
new_field=Played
|
||||||
recset -f $f --rename $new_field
|
recset -f ${f} --rename ${new_field}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Read
|
## Read
|
||||||
@@ -55,20 +55,20 @@ recset -f $f --rename $new_field
|
|||||||
Check how many records the database has:
|
Check how many records the database has:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
recinf $database
|
recinf ${database}
|
||||||
```
|
```
|
||||||
|
|
||||||
Look at just the games you've never played:
|
Look at just the games you've never played:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
recsel --expression="Played = 'no'" $database
|
recsel --expression="Played = 'no'" ${database}
|
||||||
```
|
```
|
||||||
|
|
||||||
Print how many, then just print the names:
|
Print how many, then just print the names:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
recsel -e "Played = 'no'" --count $database
|
recsel -e "Played = 'no'" --count ${database}
|
||||||
recsel -e "Played = 'no'" --print=Name $database
|
recsel -e "Played = 'no'" --print=Name ${database}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Update
|
## Update
|
||||||
@@ -79,8 +79,8 @@ To change a game's `Played` field from `no` to `yes`, use `recset` to specify th
|
|||||||
num=0
|
num=0
|
||||||
f=Played
|
f=Played
|
||||||
value=yes
|
value=yes
|
||||||
recsel --number=$num $database
|
recsel --number=${num} ${database}
|
||||||
recset --number=$num -f $f --set=$value $database
|
recset --number=${num} -f ${f} --set=${value} ${database}
|
||||||
```
|
```
|
||||||
|
|
||||||
Find all games with a playtime of `30`, and set the field `Max_Players` to `4`.
|
Find all games with a playtime of `30`, and set the field `Max_Players` to `4`.
|
||||||
@@ -102,22 +102,22 @@ Remove `Played` record from first game:
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
num=0
|
num=0
|
||||||
recset --number=$num -f Played --delete $database
|
recset --number=${num} -f Played --delete ${database}
|
||||||
```
|
```
|
||||||
|
|
||||||
You can comment the line instead of deleting it:
|
You can comment the line instead of deleting it:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
num=1
|
num=1
|
||||||
recset --number=$num -f Played --delete $database
|
recset --number=${num} -f Played --delete ${database}
|
||||||
recsel $database
|
recsel ${database}
|
||||||
cat $database
|
cat ${database}
|
||||||
```
|
```
|
||||||
|
|
||||||
Delete an entire record:
|
Delete an entire record:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
num=2
|
num=2
|
||||||
recdel --number=$num $database
|
recdel --number=${num} ${database}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
title: Arch on a Raspberry Pi 4
|
title: Arch on a Raspberry Pi 4
|
||||||
tags:
|
tags:
|
||||||
- distros
|
- distros
|
||||||
- raspberry pi
|
|
||||||
- rpi
|
- rpi
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
+102
-1
@@ -1,7 +1,8 @@
|
|||||||
%rec: example
|
%rec: example
|
||||||
%key: filename
|
%key: name
|
||||||
%type: note line
|
%type: note line
|
||||||
|
|
||||||
|
name: Default systemd service file
|
||||||
filename: default.service
|
filename: default.service
|
||||||
bin: systemd
|
bin: systemd
|
||||||
usage: mv {{filename}} /usr/lib/systemd/system/
|
usage: mv {{filename}} /usr/lib/systemd/system/
|
||||||
@@ -31,6 +32,7 @@ content: [Unit]
|
|||||||
+ Alias=test.service
|
+ Alias=test.service
|
||||||
+
|
+
|
||||||
|
|
||||||
|
name: Example sc-im file
|
||||||
filename: food.sc
|
filename: food.sc
|
||||||
bin: sc-im
|
bin: sc-im
|
||||||
usage: {{bin}} {{filename}}
|
usage: {{bin}} {{filename}}
|
||||||
@@ -81,8 +83,11 @@ content: # This data file was generated by the Spreadsheet Calculator Improvised
|
|||||||
+ pad 4 A10
|
+ pad 4 A10
|
||||||
+ goto A10
|
+ goto A10
|
||||||
|
|
||||||
|
name: Example makefile producing html from markdown
|
||||||
filename: lowdown.mk
|
filename: lowdown.mk
|
||||||
bin: make
|
bin: make
|
||||||
|
bin: lowdown
|
||||||
|
bin: fortune
|
||||||
usage: {{bin}} -f {{filename}} example
|
usage: {{bin}} -f {{filename}} example
|
||||||
content: output: all
|
content: output: all
|
||||||
+
|
+
|
||||||
@@ -121,6 +126,7 @@ content: output: all
|
|||||||
+ clean :
|
+ clean :
|
||||||
+ rm -rf public html
|
+ rm -rf public html
|
||||||
|
|
||||||
|
name: Default makefile
|
||||||
filename: Makefile
|
filename: Makefile
|
||||||
bin: make
|
bin: make
|
||||||
usage: make
|
usage: make
|
||||||
@@ -153,3 +159,98 @@ content: ### Variables
|
|||||||
+ .PHONY: clean
|
+ .PHONY: clean
|
||||||
+ clean: ## Remove generated files.
|
+ clean: ## Remove generated files.
|
||||||
+ $(RM) $(defaults)
|
+ $(RM) $(defaults)
|
||||||
|
|
||||||
|
name: Issues tracker
|
||||||
|
filename: Makefile
|
||||||
|
bin: make
|
||||||
|
content: hdr = @printf "\n\033[37;1;4m%s\033[0m\n"
|
||||||
|
+ msg = @printf "\033[37;1m%s\033[0m\n"
|
||||||
|
+
|
||||||
|
+ issues = $(wildcard open/*) $(wildcard closed/*)
|
||||||
|
+
|
||||||
|
+ number_of_issues != echo $(issues) | wc -w
|
||||||
|
+
|
||||||
|
+ name = open/issue_$(number_of_issues).md
|
||||||
|
+
|
||||||
|
+ last_modified != ls -t open/* 2>/dev/null | head -1
|
||||||
|
+ ifndef last_modified
|
||||||
|
+ setup:
|
||||||
|
+ @mkdir open closed
|
||||||
|
+ @git init
|
||||||
|
+ @echo '---' > open/issue_1.md
|
||||||
|
+ @echo 'title: Setup git' >> open/issue_1.md
|
||||||
|
+ @echo 'priority: high' >> open/issue_1.md
|
||||||
|
+ @printf 'responsible: ' >> open/issue_1.md
|
||||||
|
+ @git config user.name >> open/issue_1.md
|
||||||
|
+ @echo '---' >> open/issue_1.md
|
||||||
|
+ @echo 'Push to a remote repository' >> open/issue_1.md
|
||||||
|
+ @git add $(MAKEFILE_LIST) open/issue_1.md
|
||||||
|
+ @git commit -m'Init the git!'
|
||||||
|
+ $(info Check issue 1)
|
||||||
|
+ $(info Run make again)
|
||||||
|
+ endif
|
||||||
|
+
|
||||||
|
+ open_issues = $(wildcard open/*)
|
||||||
|
+ closed_issues = $(patsubst open/%, closed/%, $(open_issues))
|
||||||
|
+
|
||||||
|
+ EDITOR ?= vi
|
||||||
|
+
|
||||||
|
+ close_issue_command = @git commit --message "Close $$(basename -s .md $(last_modified) | tr '_' ' ')"
|
||||||
|
+
|
||||||
|
+ random_helper = $(shell git shortlog -se | sort -R | head -1 | cut -d '<' -f2 | tr -d '>')
|
||||||
|
+
|
||||||
|
+ contact = Get outside help
|
||||||
|
+ ifeq ($(MAKECMDGOALS),help)
|
||||||
|
+ contact = Email $(random_helper)
|
||||||
|
+ endif
|
||||||
|
+
|
||||||
|
+ help:
|
||||||
|
+ @printf "\033[36m%s\t\033[0m %s\n" "help" "$(contact)"
|
||||||
|
+ @printf "\033[36m%s\t" "done"
|
||||||
|
+ @printf "\033[0m %s " "Close $$(basename -s .md $(last_modified) | tr '_' ' ')"
|
||||||
|
+ @printf "\033[0m %s\n" "[$$(grep -Pom1 'title: \K.*' $(last_modified))]"
|
||||||
|
+ @awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z._-]+:.*?## / {printf "\033[36m%s\033[0m : %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \
|
||||||
|
+ column -s ':' -t
|
||||||
|
+
|
||||||
|
+ $(closed_issues): closed/%.md: open/%.md
|
||||||
|
+ @git add $<
|
||||||
|
+ @git mv $< $@
|
||||||
|
+ $(close_issue_command)
|
||||||
|
+
|
||||||
|
+ .PHONY: issue
|
||||||
|
+ issue: $(name) ## Make an issue
|
||||||
|
+ $(name):
|
||||||
|
+ @echo '---' > $(name)
|
||||||
|
+ @read -p 'Title? ' title && echo title: $$title >> $@
|
||||||
|
+ @echo priority: low >> $@
|
||||||
|
+ @echo responsible: $(shell git config user.name) >> $@
|
||||||
|
+ @echo '---' >> $@
|
||||||
|
+ @printf '\n\n' >> $@
|
||||||
|
+ @$(EDITOR) +7 $@
|
||||||
|
+ @git add $@
|
||||||
|
+ @git commit --quiet --message "$$(grep -Pom1 'title: \K.*' $@)"
|
||||||
|
+ $(info Commit created, remember to push!)
|
||||||
|
+
|
||||||
|
+ .PHONY: done
|
||||||
|
+ done:
|
||||||
|
+ $(info Closing $(shell basename -s .md $(last_modified) | tr '_' ' '))
|
||||||
|
+ @git add $(last_modified)
|
||||||
|
+ @git mv $(last_modified) closed/
|
||||||
|
+ $(close_issue_command)
|
||||||
|
+
|
||||||
|
+ .PHONY: stats
|
||||||
|
+ stats: ## Summarise issue
|
||||||
|
+ $(hdr) "Priorities"
|
||||||
|
+ $(msg) "$$(head -n 7 $(wildcard open/*) | sort | grep -Po 'priority: \K.*' | uniq -c)"
|
||||||
|
+ $(msg) "$$(ls closed/ | wc -l) closed"
|
||||||
|
+ $(hdr) "Holders"
|
||||||
|
+ $(msg) "$$(head -n 7 $(wildcard open/*) | grep -Po 'responsible: \K.*' | tr [:upper:] [:lower:] | sort | uniq -c)"
|
||||||
|
+
|
||||||
|
+ .PHONY: rundown
|
||||||
|
+ rundown: ## Summarize events
|
||||||
|
+ @printf "\033[33;5m# %s\033[0m\n" "Outstanding Calamities"
|
||||||
|
+ @$(foreach bug, $(wildcard open/*.md), \
|
||||||
|
+ a="$$(lowdown -X responsible $(bug))" && \
|
||||||
|
+ n="$$(echo $(bug) | cut -d_ -f2 | cut -d. -f1)" && \
|
||||||
|
+ t="$$(lowdown -X title $(bug))" && echo "$$n: $$t ($$a)" ;\
|
||||||
|
+ )
|
||||||
|
|||||||
@@ -1,78 +0,0 @@
|
|||||||
---
|
|
||||||
title: pi-hole-server
|
|
||||||
tags:
|
|
||||||
- distros
|
|
||||||
---
|
|
||||||
# Installation
|
|
||||||
|
|
||||||
## Arch
|
|
||||||
|
|
||||||
```sh
|
|
||||||
yay -S pi-hole-server
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo systemctl enable --now pihole-FTL
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo systemctl disable --now systemd-resolved
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo rm -f /dev/shm/FTL-\*
|
|
||||||
```
|
|
||||||
|
|
||||||
## Debian
|
|
||||||
|
|
||||||
Debian has a long, boring setup.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo apt-get install wget curl net-tools gamin lighttpd lighttpd-mod-deflate
|
|
||||||
curl -sSL https://install.pi-hole.net | PIHOLE_SKIP_OS_CHECK=true sudo -E bash
|
|
||||||
```
|
|
||||||
|
|
||||||
# Setup
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo usermod -aG pihole $USER
|
|
||||||
```
|
|
||||||
|
|
||||||
Remove that google dns server.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
pihole -a setdns 9.9.9.9 1.0.0.1
|
|
||||||
```
|
|
||||||
|
|
||||||
Disable pihole password by setting a blank password.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
pihole -a -p
|
|
||||||
```
|
|
||||||
|
|
||||||
Get a new list of blocked domains, then reload:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
pihole -g -r
|
|
||||||
```
|
|
||||||
|
|
||||||
Every so often, run `pihole -g` again (perhaps put it in crontab).
|
|
||||||
|
|
||||||
## Check the Pihole
|
|
||||||
|
|
||||||
Observe the pihole's output while you ask it a question:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
pihole -t
|
|
||||||
```
|
|
||||||
|
|
||||||
Then ask the question from another computer:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
dig @[ pihole ip ] archlinux.org
|
|
||||||
```
|
|
||||||
|
|
||||||
## System-Wide Setup
|
|
||||||
|
|
||||||
To make the pihole work for the entire Network, enter your router and set the DNS server as nothing but your pihole.
|
|
||||||
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
title: Stop email impersonating your domain
|
||||||
|
tags:
|
||||||
|
- networking
|
||||||
|
requires:
|
||||||
|
- networking/dns_records.md
|
||||||
|
---
|
||||||
|
|
||||||
|
There is nothing to stop scammers from sending email claiming to be coming from your domain.
|
||||||
|
And the older it gets, the more valuable it is for spoofing.
|
||||||
|
|
||||||
|
Just add these two TXT records to the DNS for your domain:
|
||||||
|
|
||||||
|
|
||||||
|
Name | Type | Value
|
||||||
|
:------|:----:|:-----
|
||||||
|
@ | TXT | v=spf1 -all
|
||||||
|
_dmarc | TXT | v=DMARC1; p=reject;
|
||||||
|
|
||||||
|
The first says there is not a single SMTP server on earth authorized to send email on behalf of your domain.
|
||||||
|
The second says that any email that says otherwise should be trashed.
|
||||||
|
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
markdown = $(wildcard */*.md */*/*.md)
|
||||||
|
|
||||||
|
publish = $(patsubst %, .publish/%, $(markdown))
|
||||||
|
|
||||||
|
.dbs/requires.fmt: | .dbs/
|
||||||
|
echo "- [{{requires_title}}]({{requires_path}})" > $@
|
||||||
|
|
||||||
|
$(publish): .publish/%.md: %.md | .dbs/notes.rec .dbs/requires.fmt
|
||||||
|
mkdir -p $(@D)
|
||||||
|
sed -n '1,/^---$$/p' $< > $@
|
||||||
|
test "$$(recsel -t guide -j requires .dbs/notes.rec -e "path = '$<'" -c)" -lt 1 \
|
||||||
|
|| { printf '\n---\n%s\n\n' "**Requirements**" >> $@ \
|
||||||
|
&& recsel -t guide -j requires .dbs/notes.rec -e "path = '$<'" -p requires_title,requires_path | recfmt -f .dbs/requires.fmt >> $@ \
|
||||||
|
&& printf '\n%s\n\n' '---' >> $@ ;}
|
||||||
|
sed '1,/---/d' $< >> $@
|
||||||
|
|
||||||
|
cmds != recsel command.rec -t command -G bin -CP bin | sort -u
|
||||||
|
lists = $(patsubst %,.publish/lists/%.md, $(cmds))
|
||||||
|
|
||||||
|
get_title = printf 'title: %s\n' '${1}'
|
||||||
|
get_tags = recsel -t $(basename $<) $< -G bin \
|
||||||
|
-e 'bin = "$(1)"' -U -CP tag,bin | \
|
||||||
|
sed 's/.*/- &/'
|
||||||
|
|
||||||
|
list_commands = recsel -t $(basename $<) $< -e 'bin = "$(1)"' | \
|
||||||
|
recfmt -f lists.fmt
|
||||||
|
|
||||||
|
.publish/lists/:| .publish/
|
||||||
|
|
||||||
|
$(lists): .publish/lists/%.md: command.rec | .publish/lists/
|
||||||
|
@printf '%s\n' '---' > $@
|
||||||
|
@$(call get_title,$(basename $(notdir $@))) >> $@
|
||||||
|
@printf '%s\n' 'tags: ' >> $@
|
||||||
|
@$(call get_tags,$(basename $(notdir $@))) >> $@
|
||||||
|
@printf '%s\n' '---' >> $@
|
||||||
|
@$(call list_commands,$(basename $(notdir $@))) >> $@
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: publish
|
||||||
|
publish: $(lists) $(publish) ## Web publishable web pages
|
||||||
|
|
||||||
@@ -68,3 +68,9 @@ x="$(!!)"
|
|||||||
echo $x
|
echo $x
|
||||||
for file in $x ; do fortune > $file ; done
|
for file in $x ; do fortune > $file ; done
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# See Also
|
||||||
|
|
||||||
|
- [Readline](shell/readline.md)
|
||||||
|
- [Shell tips](shell/shell_tips.md)
|
||||||
|
|
||||||
|
|||||||
@@ -25,3 +25,9 @@ until [ "$x" -eq "1" ]; do
|
|||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
```
|
```
|
||||||
|
|
||||||
|
[Slow down the terminal][slow] then enjoy some [old ASCII art][ascii].
|
||||||
|
|
||||||
|
[slow]: shell/slow.md
|
||||||
|
[ascii]: http://artscene.textfiles.com/vt100/
|
||||||
|
|
||||||
|
|||||||
+23
-1
@@ -15,5 +15,27 @@ tags:
|
|||||||
# Search & Clear Highlights
|
# Search & Clear Highlights
|
||||||
|
|
||||||
You can search in many programs by using `/`.
|
You can search in many programs by using `/`.
|
||||||
Most programs let you clearn the highlighting with `<Esc>+u`.
|
Most programs let you clear the highlighting with `<Esc>+u`.
|
||||||
|
|
||||||
|
|
||||||
|
## Track Live Changes
|
||||||
|
|
||||||
|
Follow a file as new lines are added to it:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
tail -f *somefile*
|
||||||
|
```
|
||||||
|
|
||||||
|
See changes in a directory, as it changes:
|
||||||
|
|
||||||
|
`watch -d ls *directory*`
|
||||||
|
|
||||||
|
Or use the `-g` flag to exit once the output changes.
|
||||||
|
This command will look at whether you're connected to the internet, and turn into a rainbow once the connection hits.
|
||||||
|
|
||||||
|
> watch -g ip address && clear && ip address | lolcat
|
||||||
|
|
||||||
|
|
||||||
|
# See Also
|
||||||
|
|
||||||
|
- [Bash tips](shell/bash_tips.md)
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
title: Slow the Terminal Down
|
||||||
|
tags:
|
||||||
|
- fun
|
||||||
|
---
|
||||||
|
|
||||||
|
Slow the terminal to the old rates with a pipe and perl:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ff=/tmp/bashpipe
|
||||||
|
mkfifo $ff
|
||||||
|
( cat $ff | perl -We 'use Time::HiRes;$|++;while(read(STDIN,$c,1)){Time::HiRes::usleep(15000);print $c;}' ) & exec &> $ff
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
- Try running `dir` and `dir -F`!
|
||||||
|
- Don't run interactive commands like `vim` or `top`!
|
||||||
|
|
||||||
|
You can make it into a bash function by putting this into your `~/.bashrc`:
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
slow ()
|
||||||
|
{
|
||||||
|
unset VISUAL;
|
||||||
|
EDITOR=ed;
|
||||||
|
alias ls='dir -F';
|
||||||
|
export PS1='[$?] \W $ ';
|
||||||
|
ff=/tmp/bashpipe_$(date +%s);
|
||||||
|
mkfifo $ff 2> /dev/null;
|
||||||
|
( cat $ff | perl -We 'use Time::HiRes;$|++;while(read(STDIN,$c,1)){Time::HiRes::usleep(15000);print $c;}' ) & exec &> $ff;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Then type:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
exec bash
|
||||||
|
slow
|
||||||
|
```
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
---
|
|
||||||
title: bash tips
|
|
||||||
tags:
|
|
||||||
- shell
|
|
||||||
- POSIX
|
|
||||||
---
|
|
||||||
## Track Live Changes
|
|
||||||
|
|
||||||
See changes in a file as it changes:
|
|
||||||
|
|
||||||
`tail -f *somefile*`
|
|
||||||
|
|
||||||
See changes in a directory, as it changes:
|
|
||||||
|
|
||||||
`watch -d ls *directory*`
|
|
||||||
|
|
||||||
Or use the `-g` flag to exit once the output changes.
|
|
||||||
This command will look at whether you're connected to the internet, and turn into a rainbow once the connection hits.
|
|
||||||
|
|
||||||
> watch -g ip address && clear && ip address | lolcat
|
|
||||||
|
|
||||||
## Automatic Renaming
|
|
||||||
|
|
||||||
There are a bunch of files:
|
|
||||||
|
|
||||||
* Column CV.aux
|
|
||||||
* Column CV.log
|
|
||||||
* Column CV.out
|
|
||||||
* Column CV.pdf
|
|
||||||
* Column CV.tex
|
|
||||||
* tccv.cls
|
|
||||||
|
|
||||||
Goal: swap the word "Column" for "Alice" in all files.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
IFS=$'\n'
|
|
||||||
for f in $(find . -name "Col*"); do
|
|
||||||
mv "$f" $(echo "$f" | sed s/Column/Alice/)
|
|
||||||
done
|
|
||||||
```
|
|
||||||
|
|
||||||
IFS is the field separator. This is required to denote the different files as marked by a new line, and not the spaces.
|
|
||||||
|
|
||||||
(Alternatively, just install `renameutils` and do `rename Column Alice *`)
|
|
||||||
|
|
||||||
## Arguments and Input
|
|
||||||
|
|
||||||
The `rm' program takes arguments, but not `stdin' from a keyboard, and therefore programs cannot pipe results into rm.
|
|
||||||
To fix this, use `xargs` to turn the stdin into an argument.
|
|
||||||
For example, if we have a list of files called `list.txt' then we could use cat as so:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
cat list.txt | xargs rm
|
|
||||||
```
|
|
||||||
|
|
||||||
Of course if spaces are included in the file, you would have to account for that.
|
|
||||||
|
|
||||||
## Numbers
|
|
||||||
|
|
||||||
Add number to variables with:
|
|
||||||
|
|
||||||
* `let "var=var+1"`
|
|
||||||
* `let "var+=1"`
|
|
||||||
* `let "var++"`
|
|
||||||
* `((++var))`
|
|
||||||
* `((var=var+1))`
|
|
||||||
* `((var+=1))`
|
|
||||||
* `var=$(expr $var + 1)`
|
|
||||||
|
|
||||||
`((n--))` works identically.
|
|
||||||
|
|
||||||
### POSIX WARNING
|
|
||||||
|
|
||||||
The number commands above work in `bash`, but not in bare-ass POSIX shells, such as `dash`.
|
|
||||||
|
|
||||||
Instead, you might do:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
x=2
|
|
||||||
x=$(( x +1 ))
|
|
||||||
x=$(( x*x ))
|
|
||||||
```
|
|
||||||
|
|
||||||
## Finding Duplicate Files
|
|
||||||
|
|
||||||
```sh
|
|
||||||
find . -type f -exec md5sum '{}' ';' | sort | uniq --all-repeated=separate -w 15 > all-files.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
## Output random characters
|
|
||||||
|
|
||||||
```sh
|
|
||||||
cat /dev/urandom | tr -cd [:alnum:] | dd bs=1 count=200 status=none && echo
|
|
||||||
```
|
|
||||||
|
|
||||||
## Temporary Working Directory
|
|
||||||
|
|
||||||
Try something out in a random directory in `/tmp` so the files will be deleted when you next shut down.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
mktemp -d
|
|
||||||
```
|
|
||||||
|
|
||||||
That gives you a random directory to mess about in.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
dir=$(mktemp -d)
|
|
||||||
for x in {A..Z}; do
|
|
||||||
fortune > "$dir"/chimpan-$x
|
|
||||||
done
|
|
||||||
cd $dir
|
|
||||||
```
|
|
||||||
|
|
||||||
### POSIX WARNING
|
|
||||||
|
|
||||||
These smart-brackets are a bash feature.
|
|
||||||
If you try to use `{A..Z}` in dash, it will think of this as a single item.
|
|
||||||
|
|
||||||
+1
-1
@@ -22,4 +22,4 @@ You can add a GUI editor as the `$VISUAL` editor:
|
|||||||
VISUAL=gedit
|
VISUAL=gedit
|
||||||
```
|
```
|
||||||
|
|
||||||
To use a true line editor, as `$EDITOR`, see [ed][writing/ed.md].
|
To use a true line editor, as `$EDITOR`, see [ed](writing/ed.md).
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
-
|
---
|
||||||
title: Making Services
|
title: Making Services
|
||||||
tags:
|
tags:
|
||||||
- systemd
|
- systemd
|
||||||
|
|||||||
+3
-12
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
title: Ed: The Standard Editor
|
title: "Ed: The Standard Editor"
|
||||||
tags:
|
tags:
|
||||||
- writing
|
- writing
|
||||||
- guide
|
- guide
|
||||||
@@ -15,18 +15,9 @@ You would type a command to the computer, and it would type out any errors.
|
|||||||
It would not waste paper, ink, and time by typing out `COMMAND RUN SUCCESSFULLY` after each command.
|
It would not waste paper, ink, and time by typing out `COMMAND RUN SUCCESSFULLY` after each command.
|
||||||
A silent machine meant a happy machine.
|
A silent machine meant a happy machine.
|
||||||
|
|
||||||
To fully appreciate `ed`, you can slow down your terminal with the following command:
|
To fully appreciate `ed`, you should [slow down your terminal].
|
||||||
|
|
||||||
```sh
|
[slow]: shell/slow.md
|
||||||
ff=/tmp/bashpipe
|
|
||||||
mkfifo $ff
|
|
||||||
( cat $ff | perl -We 'use Time::HiRes;$|++;while(read(STDIN,$c,1)){Time::HiRes::usleep(15000);print $c;}' ) & exec &> $ff
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Try running `dir` and `dir -F`!
|
|
||||||
|
|
||||||
Okay, now onto `ed`...
|
|
||||||
|
|
||||||
# Basic Usage
|
# Basic Usage
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -20,9 +20,9 @@ Keybind to exit this mode is `Ctrl+q`
|
|||||||
|
|
||||||
## Extras
|
## Extras
|
||||||
|
|
||||||
- [Learning Vim](vim/vi.md)
|
- [Learning Vim](writing/vim/vi.md)
|
||||||
- [Navigation](vim/navigate.md)
|
- [Navigation](writing/vim/navigate.md)
|
||||||
- [Completion](vim/completion.md)
|
- [Completion](writing/vim/completion.md)
|
||||||
- [Window Splits](vim/windows.md)
|
- [Window Splits](writing/vim/windows.md)
|
||||||
- [Use vim bindings in bash](vim/vim_in_bash.md)
|
- [Use vim bindings in bash](writing/vim/vim_in_bash.md)
|
||||||
- [A game to learn how to code in Vim](https://www.vim-hero.com/)
|
- [A game to learn how to code in Vim](https://www.vim-hero.com/)
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
---
|
||||||
|
title: Format a CSV file as markdown in vim
|
||||||
|
tags:
|
||||||
|
- vim
|
||||||
|
- markdown
|
||||||
|
- csv
|
||||||
|
---
|
||||||
|
|
||||||
|
The command to format CSV tables works similarly to [formatting markdown][formarkdown].
|
||||||
|
|
||||||
|
Put this in your `~/.vimrc` and use `Control + s` after highlighting a cs
|
||||||
|
|
||||||
|
```vim
|
||||||
|
vmap <C-s> :!column -ts, -o " \| "<Enter>yyp:s/[^\|:]/-/g<Enter>
|
||||||
|
```
|
||||||
|
|
||||||
|
Read a CSV file into Vim:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
r ${file}.csv
|
||||||
|
```
|
||||||
|
|
||||||
|
Select the csv output:
|
||||||
|
|
||||||
|
```csv
|
||||||
|
Transaction Date,Transaction Type,Transaction Description,Debit Amount,Credit Amount
|
||||||
|
29/12/2020,DEB,NON-GBP CASH FEE,1.50
|
||||||
|
29/12/2020,DEB,NON-GBP TRANS FEE,4.60
|
||||||
|
29/12/2020,DEB,KBA BRANKOVA 34,153.85
|
||||||
|
29/12/2020,DEB,NON-GBP PURCH FEE,0.50
|
||||||
|
29/12/2020,DEB,NON-GBP TRANS FEE,0.30
|
||||||
|
29/12/2020,DEB,BIOMARKET 2,10.36
|
||||||
|
29/12/2020,DEB,NON-GBP PURCH FEE,0.50
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Press `Control + s`:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
|
||||||
|
Transaction Date | Transaction Type | Transaction Description | Debit Amount | Credit Amount
|
||||||
|
-----------------|------------------|-------------------------|--------------|--------------
|
||||||
|
29/12/2020 | DEB | NON-GBP CASH FEE | 1.50 |
|
||||||
|
29/12/2020 | DEB | NON-GBP TRANS FEE | 4.60 |
|
||||||
|
29/12/2020 | DEB | KBA BRANKOVA 34 | 153.85 |
|
||||||
|
29/12/2020 | DEB | NON-GBP PURCH FEE | 0.50 |
|
||||||
|
29/12/2020 | DEB | NON-GBP TRANS FEE | 0.30 |
|
||||||
|
29/12/2020 | DEB | BIOMARKET 2 | 10.36 |
|
||||||
|
29/12/2020 | DEB | NON-GBP PURCH FEE | 0.50 |
|
||||||
|
```
|
||||||
|
|
||||||
|
[formarkdown]: writing/vim/md_columns.md
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
---
|
||||||
|
title: Format Markdown Columns in Vim
|
||||||
|
tags:
|
||||||
|
- writing
|
||||||
|
- vim
|
||||||
|
- markdown
|
||||||
|
- TUI
|
||||||
|
---
|
||||||
|
|
||||||
|
Got a wonky markdown table?
|
||||||
|
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
|
||||||
|
| Real Time | Game Time |
|
||||||
|
|:--|:-|
|
||||||
|
| 1 week | 1 month |
|
||||||
|
| 3 weeks | 3 months|
|
||||||
|
| 6 months | 2 years|
|
||||||
|
| 1 year | 4 years|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Vim can fix it without plugins.
|
||||||
|
Just use this snippet (type `:` to begin inputting a command):
|
||||||
|
|
||||||
|
```vim
|
||||||
|
:vmap <C-t> :!tr -s ' -' \|column -ts '\|' -o '\|'<Enter>j:s/ /-/g<Enter>k
|
||||||
|
```
|
||||||
|
|
||||||
|
Highlight the whole thing with `vap` then press `Control + t`.
|
||||||
|
Instantly, it is aligned:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
|
||||||
|
| Real Time | Game Time |
|
||||||
|
|:----------|:----------|
|
||||||
|
| 1 week | 1 month |
|
||||||
|
| 3 weeks | 3 months |
|
||||||
|
| 6 months | 2 years |
|
||||||
|
| 1 year | 4 years |
|
||||||
|
```
|
||||||
|
|
||||||
|
**NB:** This method has problems with centre-aligned columns (using `:---:`).
|
||||||
|
|
||||||
|
## Vim Run Commands
|
||||||
|
|
||||||
|
Put this in your `~/.vimrc` to make the mapping permanent:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
vmap <C-t> :!tr -s ' -' \|column -ts '\|' -o '\|'<Enter>j:s/ /-/g<Enter>k
|
||||||
|
```
|
||||||
|
|
||||||
@@ -4,8 +4,6 @@ tags:
|
|||||||
- vim
|
- vim
|
||||||
- learning
|
- learning
|
||||||
- TUI
|
- TUI
|
||||||
requires:
|
|
||||||
- writing/vim.md
|
|
||||||
---
|
---
|
||||||
|
|
||||||
1. Uninstall `vim`.
|
1. Uninstall `vim`.
|
||||||
|
|||||||
Reference in New Issue
Block a user