Compare commits

...

20 Commits

Author SHA1 Message Date
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
20 changed files with 344 additions and 244 deletions
+6 -2
View File
@@ -33,6 +33,7 @@ default += .dbs/map.fmt
echo '*' > $@.gitignore echo '*' > $@.gitignore
include cmd.mk include cmd.mk
include pub.mk
.dbs/head.rec: | .dbs/ .dbs/head.rec: | .dbs/
printf '%s\n' '%rec: guide' > $@ printf '%s\n' '%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
View File
@@ -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}"
``` ```
``` ```
+1
View File
@@ -3,6 +3,7 @@ title: profanity automation
tags: tags:
- chat - chat
- omemo - omemo
- TUI
requires: requires:
- chat/profanity.md - 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 .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/'
+5 -6
View File
@@ -251,10 +251,10 @@ tag: web
shell: sh shell: sh
aim: Run commands in background aim: Run commands in background
cmd: du -sh .* | sort -h | tail & cmd: ls -Rilt ~ &
cmd: jobs + jobs
cmd: grep -ri password /etc/ & + find ~/.cache/ -type d -exec du '{}' -h ';' | sort -h &
cmd: jobs + jobs
shell: sh shell: sh
bin: jobs bin: jobs
tag: shell tag: shell
@@ -545,7 +545,7 @@ tag: writing
aim: Edit users in /etc/passwd directly aim: Edit users in /etc/passwd directly
cmd: sudo vipw cmd: sudo vipw
note: You can't edit passwords with black magic. note: You can't edit passwords without strange cyphers.
shell: sh shell: sh
bin: vipw bin: vipw
bin: sudo bin: sudo
@@ -554,7 +554,6 @@ tag: users
aim: Edit groups in /etc/group directly aim: Edit groups in /etc/group directly
cmd: sudo vigr cmd: sudo vigr
note: You can't edit passwords with black magic.
shell: sh shell: sh
bin: vipw bin: vipw
bin: sudo bin: sudo
-1
View File
@@ -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
View File
@@ -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)" ;\
+ )
-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.
+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: %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 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)
+6
View File
@@ -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
View File
@@ -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)
+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
```
-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.
+1 -1
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
- ---
title: Making Services title: Making Services
tags: tags:
- systemd - systemd
+3 -12
View File
@@ -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
+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 - vim
- learning - learning
- TUI - TUI
requires:
- writing/vim.md
--- ---
1. Uninstall `vim`. 1. Uninstall `vim`.