Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
f4f6da1250
|
|||
|
f47a28b359
|
|||
|
77af4be50c
|
|||
|
5cae2da19c
|
|||
|
a4ca6023d1
|
|||
|
5ca15bc33f
|
|||
|
6325a32c85
|
|||
|
b50709b7c4
|
|||
|
03e3ebd748
|
|||
|
fa409cb8fb
|
|||
|
db380464a2
|
|||
|
7f91ab754c
|
|||
|
c949094bc8
|
|||
|
6289dbe32e
|
|||
|
b01fc9ff0d
|
|||
|
ffd058dc45
|
|||
|
ef7d1a0f5e
|
|||
|
b7493ddbaf
|
|||
|
c3293ec3ac
|
|||
|
23ff184688
|
@@ -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
@@ -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}"
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
@@ -3,6 +3,7 @@ title: profanity automation
|
||||
tags:
|
||||
- chat
|
||||
- omemo
|
||||
- TUI
|
||||
requires:
|
||||
- chat/profanity.md
|
||||
---
|
||||
|
||||
@@ -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/'
|
||||
|
||||
+5
-6
@@ -251,10 +251,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
|
||||
@@ -545,7 +545,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,7 +554,6 @@ 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
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
title: Arch on a Raspberry Pi 4
|
||||
tags:
|
||||
- distros
|
||||
- raspberry pi
|
||||
- rpi
|
||||
---
|
||||
|
||||
|
||||
+102
-1
@@ -1,7 +1,8 @@
|
||||
%rec: example
|
||||
%key: filename
|
||||
%key: name
|
||||
%type: note line
|
||||
|
||||
name: Default systemd service file
|
||||
filename: default.service
|
||||
bin: systemd
|
||||
usage: mv {{filename}} /usr/lib/systemd/system/
|
||||
@@ -31,6 +32,7 @@ content: [Unit]
|
||||
+ Alias=test.service
|
||||
+
|
||||
|
||||
name: Example sc-im file
|
||||
filename: food.sc
|
||||
bin: sc-im
|
||||
usage: {{bin}} {{filename}}
|
||||
@@ -81,8 +83,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 +126,7 @@ content: output: all
|
||||
+ clean :
|
||||
+ rm -rf public html
|
||||
|
||||
name: Default makefile
|
||||
filename: Makefile
|
||||
bin: make
|
||||
usage: make
|
||||
@@ -153,3 +159,98 @@ 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)" ;\
|
||||
+ )
|
||||
|
||||
@@ -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,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
|
||||
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
|
||||
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
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
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
|
||||
tags:
|
||||
- systemd
|
||||
|
||||
+3
-12
@@ -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].
|
||||
|
||||
```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
|
||||
|
||||
|
||||
@@ -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
|
||||
- learning
|
||||
- TUI
|
||||
requires:
|
||||
- writing/vim.md
|
||||
---
|
||||
|
||||
1. Uninstall `vim`.
|
||||
|
||||
Reference in New Issue
Block a user