Compare commits

...

41 Commits

Author SHA1 Message Date
andonome 58f794d7b8 Remote into new sway session 2026-06-13 09:09:35 +02:00
andonome 49452db82d How to remote into sway 2026-06-13 08:59:32 +02:00
andonome a3ffdd8ae6 CMD: share directory locally 2026-06-13 07:38:04 +02:00
andonome fe1c524dc3 Example: RSS feed 2026-06-11 14:01:57 +02:00
andonome 668d605dcb CMD: get sway info 2026-06-11 11:36:47 +02:00
andonome cc3ac0d7b0 Remove colon from rundown lists 2026-06-06 14:14:33 +02:00
andonome 8811e94b11 Soft: add standard commands 2026-06-05 17:20:30 +02:00
andonome cd7ddd15b2 CMD: sort 2026-06-03 06:07:28 +02:00
andonome 88eefd2c1e CMD: read sizes 2026-06-03 05:43:07 +02:00
andonome 54e4cc5149 Publish lists with title 'Rundown:' 2026-06-02 07:46:03 +02:00
andonome 9901404a91 Rename git setup 2026-06-02 07:36:03 +02:00
andonome 4e76fec33c Systemd fixups 2026-05-26 02:53:36 +02:00
andonome d7f8c9bae1 Rename pass setup 2026-05-25 19:52:22 +02:00
andonome 6a10468d4d Fix ed link 2026-05-24 18:41:52 +02:00
andonome ab079fedfa Fix kubernetes names 2026-05-24 18:40:14 +02:00
andonome 2bdc293263 Rename fail2ban 2026-05-24 18:37:24 +02:00
andonome 2f7ad89bbb Note setup tags 2026-05-24 18:37:16 +02:00
andonome 5e9d08286b Reformat cron 2026-05-24 18:30:36 +02:00
andonome 4c9dacbd45 Mark git-secret as a review 2026-05-24 18:30:21 +02:00
andonome 9e4889daea Remove old mpd notes 2026-05-24 18:30:12 +02:00
andonome e35e9a7766 Remove monitor notes 2026-05-24 18:29:38 +02:00
andonome f4f6da1250 Publish with all target 2026-05-19 15:02:52 +02:00
andonome f47a28b359 Consolidate shell tips 2026-05-19 14:59:34 +02:00
andonome 77af4be50c Fix editors link 2026-05-19 12:42:46 +02:00
andonome 5cae2da19c Quote ed 2026-05-19 11:44:03 +02:00
andonome a4ca6023d1 Fix systemd delimiter 2026-05-19 11:26:15 +02:00
andonome 5ca15bc33f Remove tag with space 2026-05-16 19:06:21 +02:00
andonome 6325a32c85 Make stable 2026-05-16 18:37:09 +02:00
andonome b50709b7c4 Remove extra slash in make article 2026-05-16 17:29:05 +02:00
andonome 03e3ebd748 Remove vi dependency on vim 2026-05-16 16:46:25 +02:00
andonome fa409cb8fb Publish pages to .publish/ 2026-05-16 16:27:57 +02:00
andonome db380464a2 CMD: clarify psswd edit 2026-05-16 15:42:03 +02:00
andonome 7f91ab754c Tag TUIs 2026-05-14 13:17:01 +02:00
andonome c949094bc8 Example: issues tracker as makefile 2026-05-11 14:09:49 +02:00
andonome 6289dbe32e Allow for duplicate name in example files 2026-05-11 14:07:39 +02:00
andonome b01fc9ff0d CMD: change background job example 2026-05-08 19:13:30 +02:00
andonome ffd058dc45 Reformat profanity 2026-05-08 16:06:46 +02:00
andonome ef7d1a0f5e Note: format csv as md in vim 2026-05-08 14:39:39 +02:00
andonome b7493ddbaf Note: format markdown with vim 2026-05-08 14:34:08 +02:00
andonome c3293ec3ac Separate slow terminal as note. 2026-05-08 14:00:49 +02:00
andonome 23ff184688 Remove outdated pi hole server 2026-05-08 13:53:14 +02:00
37 changed files with 536 additions and 331 deletions
+6 -2
View File
@@ -33,6 +33,7 @@ default += .dbs/map.fmt
echo '*' > $@.gitignore
include cmd.mk
include pub.mk
.dbs/head.rec: | .dbs/
printf '%s\n' '%rec: guide' > $@
@@ -58,6 +59,7 @@ include cmd.mk
sed '1,/^---$$/d' $$entry | sed 's/^.*/+ &/' ;\
echo '' ;\
done >> $@
recfix $@
.dbs/requires.rec: .dbs/new.rec
recinf -d $< > $@
@@ -100,7 +102,7 @@ map: .dbs/requires.rec .dbs/map.fmt ## Show knowledge dependency map
.PHONY: clean
clean: ## Remove all generated files
$(RM) -r $(default) .dbs/
$(RM) -r $(default) .dbs/ .publish/
.PHONY: article
article: */ */*/ ## Write a new article
@@ -109,7 +111,9 @@ article: */ */*/ ## Write a new article
&& filename="$$(echo "$$name" \
| cut -d: -f1 \
| 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
all: $(default) ## All file targets
+2 -1
View File
@@ -3,6 +3,7 @@ title: profanity
tags:
- chat
- omemo
- TUI
---
# 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).
```
/account set ${name}@${host} eval_password pass *xmpp*
/account set ${name}@${host} eval_password "pass ${account}"
```
```
+1
View File
@@ -3,6 +3,7 @@ title: profanity automation
tags:
- chat
- omemo
- TUI
requires:
- chat/profanity.md
---
+1 -20
View File
@@ -1,25 +1,6 @@
cmds != recsel command.rec -t command -G bin -CP bin | sort -u
lists = $(patsubst %,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
$(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: function
function: ## Output a search function for .bashrc
function: | db.rec ## Output a search function for .bashrc
${MAKE} --silent --touch query
printf '%s\n' 'lk(){'
${MAKE} --silent --dry-run query | sed 's/^/\t/'
+56 -8
View File
@@ -200,6 +200,13 @@ shell: sh
bin: fzf
tag: comfy
aim: Read the minimal size of a git repo
cmd: git count-objects -vH | grep -Po 'size-pack: \K.*'
note: Git repositories are never at their minimal size.
shell: sh
bin: git
tag: size
aim: Email a pull request which points to your git server
tag: git
shell: sh
@@ -251,10 +258,10 @@ tag: web
shell: sh
aim: Run commands in background
cmd: du -sh .* | sort -h | tail &
cmd: jobs
cmd: grep -ri password /etc/ &
cmd: jobs
cmd: ls -Rilt ~ &
+ jobs
+ find ~/.cache/ -type d -exec du '{}' -h ';' | sort -h &
+ jobs
shell: sh
bin: jobs
tag: shell
@@ -286,7 +293,7 @@ shell: sh
bin: journalctl
tag: system
aim: Find errors since a date
aim: Find service errors in systemd since a date
cmd: date=2027-01-01
+ journalctl --since=${date} --grep="EXT4-fs error"
shell: sh
@@ -294,7 +301,8 @@ bin: journalctl
tag: system
aim: Limit the systemd's journal size to 2 gigabytes
cmd: journalctl --vacuum-size=2G
cmd: journalctl --disk-usage
+ journalctl --vacuum-size=2G
+ journalctl --disk-usage
shell: sh
bin: journalctl
@@ -413,6 +421,13 @@ bin: ntpd
tag: time
tag: system
aim: Convert bytes to human readable size
cmd: b=10392309
+ echo "$b" | numfmt --to=eic
shell: sh
bin: numfmt
tag: size
aim: Uncompress a PDF
cmd: pdftk ${input}.pdf output ${output}.pdf uncompress
shell: sh
@@ -477,6 +492,14 @@ bin: ssh
tag: system
tag: comfy
aim: List enabled systemd services
cmd: systemctl list-unit-files --state enabled
cmd: systemctl --user list-unit-files --state enabled
shell: sh
bin: systemd
tag: system
tag: service
aim: Check a service
cmd: sudo systemctl status mpd
shell: sh
@@ -545,7 +568,7 @@ tag: writing
aim: Edit users in /etc/passwd directly
cmd: sudo vipw
note: You can't edit passwords with black magic.
note: You can't edit passwords without strange cyphers.
shell: sh
bin: vipw
bin: sudo
@@ -554,9 +577,34 @@ tag: users
aim: Edit groups in /etc/group directly
cmd: sudo vigr
note: You can't edit passwords with black magic.
shell: sh
bin: vipw
bin: sudo
tag: system
tag: groups
aim: Check current keyboard layout on sway
cmd: swaymsg -t get_inputs --raw | jq -r '.[0].xkb_active_layout_name'
bin: sway
bin: jq
tag: keyboard
tag: locale
shell: sh
aim: Show name of currently selected app in sway
cmd: swaymsg -t get_tree | jq -C '.. | select(.type?) | select(.focused==true)'
bin: sway
bin: jq
tag: bar
shell: sh
aim: Share a directory as a local website
cmd: python3 -m http.server
note: Anyone can go to your computer's IP address and access all files in the current directory.
shell: sh
bin: python3
tag: tip
tag: network
tag: share
cmd: qrencode -t ansi "$(ip route show | grep -Pom1 'src \K[\d.]+')"
+ sudo python -m http.server 80
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: git
title: Setup git
tags:
- data
- setup
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: git-secret
title: "Review: git-secret"
tags:
- data
- git
+1
View File
@@ -2,6 +2,7 @@
title: newsboat
tags:
- RSS
- Setup
---
Create the configuration directory before you start, and add at least 1 URL.
+1
View File
@@ -3,6 +3,7 @@ title: Newsraft
tags:
- data
- RSS
- Setup
---
# Setup
+2 -1
View File
@@ -1,7 +1,8 @@
---
title: pass
title: Store passwords
tags:
- data
- Setup
- credentials
- secrets
requires:
+1
View File
@@ -10,5 +10,6 @@ requires:
- networking/nginx.md
---
- [Soft-Serve with https](soft-serve/commands.md)
- [Soft-Serve with https](soft-serve/soft_https.md)
- [Maintenance](soft-serve/soft_maintenance.md)
+29
View File
@@ -0,0 +1,29 @@
---
title: Soft-Serve Commands
tags:
- data
- git server
- CLI
requires:
- data/git.md
- networking/ssh.md
---
Some commands to try with an active soft server:
```sh
ssh -p 2222 splint.rs repo list
ssh -p 2222 splint.rs repo info nd6
ssh -p 2222 splint.rs repo tree nd6 /
ssh -p 2222 splint.rs repo info newsraft
ssh -p 2222 splint.rs repo tree newsraft main doc
ssh -p 2222 splint.rs repo tree mkdots all scripts
ssh -p 2222 splint.rs repo -cl cat mkdots all scripts/nb | less -R
```
-1
View File
@@ -2,7 +2,6 @@
title: Arch on a Raspberry Pi 4
tags:
- distros
- raspberry pi
- rpi
---
+128 -5
View File
@@ -1,7 +1,7 @@
%rec: example
%key: filename
%type: note line
%key: name
name: Default systemd service file
filename: default.service
bin: systemd
usage: mv {{filename}} /usr/lib/systemd/system/
@@ -31,6 +31,7 @@ content: [Unit]
+ Alias=test.service
+
name: Example sc-im file
filename: food.sc
bin: sc-im
usage: {{bin}} {{filename}}
@@ -81,8 +82,11 @@ content: # This data file was generated by the Spreadsheet Calculator Improvised
+ pad 4 A10
+ goto A10
name: Example makefile producing html from markdown
filename: lowdown.mk
bin: make
bin: lowdown
bin: fortune
usage: {{bin}} -f {{filename}} example
content: output: all
+
@@ -121,6 +125,7 @@ content: output: all
+ clean :
+ rm -rf public html
name: Default makefile
filename: Makefile
bin: make
usage: make
@@ -142,9 +147,7 @@ content: ### Variables
+
+ .PHONY: help
+ help:
+ @awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z._-]+:.*?## / {printf "\033[36m%s\033[0m : %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \
+ sort | \
+ column -s ':' -t
+ @awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z._-]+:.*?## / {printf "\033[36m%s\033[0m : %s\n", $$1, $$2}' $(MAKEFILE_LIST) | + sort | + column -s ':' -t
+
+ .PHONY: check
+ check: ## Check you have the required dependencies
@@ -153,3 +156,123 @@ content: ### Variables
+ .PHONY: clean
+ clean: ## Remove generated files.
+ $(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)" ;+ )
name: RSS feed
filename: rss.xml
note: Only 'description', 'link', and 'title' are required.
+
+ Extra fields include 'textInput' (for a paragraph about the feed), 'skipHours' (for the hours to wait before refreshing), and 'language'.
content: <?xml version="1.0" encoding="UTF-8" ?>
+ <rss version="2.0">
+
+ <channel>
+ <title>{{title}}</title>
+ <link>{{url}}</link>
+ <generator>Recutils</generator>
+ <docs>https://www.w3schools.com/XML/xml_rss.asp</docs>
+ <skipDays>{{frequency}}</skipDays>
+ <description>{{description}}</description>
note: Output the next content field separately to produce multiple post items.
content: <item>
+ <guid>{{post_id}}</guid>
+ <category>{{post_category}}</category>
+ <pubDate>{{post_date}}</pubDate>
+ <title>{{post_title}}</title>
+ <link>{{url}}/{{post_link}}</link>
+ <description>{{post_description}}</description>
+ <source>{{post_source}}</source>
+ </item>
note: The last content field closes the XML tags opened in the first content field.
content: </channel>
+
+ </rss>
-17
View File
@@ -1,17 +0,0 @@
---
title: monitor
tags:
- hardware
---
See screen size
```sh
xrandr -q
```
Automatically configure:
```sh
xrandr --auto
```
+3 -1
View File
@@ -1,7 +1,9 @@
---
title: fail2ban
title: fail2ban for ssh
tags:
- networking
- system
- Setup
requires:
- networking/ssh.md
---
-78
View File
@@ -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.
+49
View File
@@ -0,0 +1,49 @@
---
title: Remote Desktop between Sway
tags:
- networking
requires:
- networking/ssh.md
---
# On the Host
Install and run `wayvnc`.
```sh
export WAYLAND_DISPLAY=wayland-1
wayvnc
```
Only the `localhost` can access this (highly insecure) desktop sharing, at port 5900.
# On the Client
You'll need to disable your main modifier key on the client while accessing the host.
Edit `~/.config/sway/config`, and create a new `passthrough` mode where the modifier key does nothing.
```config
mode passthrough {
bindsym $mod+c mode default
}
bindsym $mod+c mode passthrough
```
Reload sway to make the changes take effect.
```sh
swaymsg reload
```
Use `ssh` to grab the host's port 5900.
```sh
ssh -L 5900:localhost:5900 ${remote_username}@${remote_ip}
```
Leave that session running, and connect with `vncviewer`:
```sh
vncviewer localhost:5900
```
+22
View File
@@ -0,0 +1,22 @@
---
title: New Sway Remote Desktop
tags:
- networking
requires:
- networking/remote_sway.md
---
Check the host is using only one display:
```sh
test "$WAYLAND_DISPLAY" = "wayland-1"
```
Start a new sway session, and a `wayvnc` session:
```sh
WLR_BACKENDS=headless WLR_LIBINPUT_NO_DEVICES=1 sway &
WAYLAND_DISPLAY=wayland-2 wayvnc
```
On the client, [connect as usual](networking/remote_sway.md).
+1 -2
View File
@@ -8,9 +8,8 @@ tags:
Try out basic ssh by accessing `git.charm.sh`, without needing authentication:
```sh
ssh git.charm.sh
ssh -t git.charm.sh
```
Start an ssh server to try it out.
+42
View File
@@ -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: "Rundown: %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
+6
View File
@@ -68,3 +68,9 @@ x="$(!!)"
echo $x
for file in $x ; do fortune > $file ; done
```
# See Also
- [Readline](shell/readline.md)
- [Shell tips](shell/shell_tips.md)
+6
View File
@@ -25,3 +25,9 @@ until [ "$x" -eq "1" ]; do
sleep 1
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
View File
@@ -15,5 +15,27 @@ tags:
# Search & Clear Highlights
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)
+40
View File
@@ -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
```
-53
View File
@@ -1,53 +0,0 @@
---
title: mpd
tags:
- sound
---
# Setup
## Configuration
This is a minimum configuration file for /etc/mpd.conf
> music_directory "/var/lib/mpd/music"
>
> playlist_directory "/var/lib/mpd/playlists"
>
> db_file "/var/lib/mpd/mpd.db"
>
>
> pid_file "/run/mpd/mpd.pid"
>
> state_file "/var/lib/mpd/mpdstate"
>
>
> user "mpd"
>
> audio_output {
> type "pulse"
> name "My Pulse Output"
> }
>
> audio_output {
> type "fifo"
> name "my_fifo"
> path "/tmp/mpd.fifo"
> format "44100:16:2"
> }
You can use alsa instead of pulse, but don't unless you're on a Pi.
Since this is run as the mpd user, you'll need to grant that user pulse acceess, often with the user-group `pulse` or `pulse-access`, but your distro may vary.
```sh
sudo usermod -aG pulse-access mpd
```
Working with mpd will be easier if you have access to its files, so maybe:
```sh
sudo usermod -aG mpd $USER
```
-118
View File
@@ -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.
-3
View File
@@ -4,9 +4,6 @@ tags:
- basics
- time
---
# Cronie
The `cronie` program is also known as `crond`.
## Install
+1 -1
View File
@@ -22,4 +22,4 @@ You can add a GUI editor as the `$VISUAL` editor:
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
View File
@@ -6,6 +6,7 @@ tags:
- makefiles
- graphviz
- python
- Setup
requires:
- system/makefiles.md
---
+2 -2
View File
@@ -1,5 +1,5 @@
-
title: Making Services
---
title: Make a Service
tags:
- systemd
---
@@ -4,6 +4,7 @@ tags:
- virtualization
- kubernetes
- minikube
- Setup
requires:
- virtualization/docker.md
---
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: Proxy API
title: Kubernetes Proxy API
tags:
- virtualization
- kubernetes
+3 -12
View File
@@ -1,5 +1,5 @@
---
title: Ed: The Standard Editor
title: "Ed: The Standard Editor"
tags:
- writing
- 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.
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][slow].
```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`!
Okay, now onto `ed`...
[slow]: shell/slow.md
# Basic Usage
+52
View File
@@ -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
+53
View File
@@ -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
```
-2
View File
@@ -4,8 +4,6 @@ tags:
- vim
- learning
- TUI
requires:
- writing/vim.md
---
1. Uninstall `vim`.