Compare commits

...

25 Commits

Author SHA1 Message Date
68734cfd1b include markdown as a variable 2026-04-29 17:42:11 +02:00
019736de05 place template makefile 2026-04-29 17:39:37 +02:00
76be2fbd3c fix links 2026-04-29 14:35:17 +02:00
34ef924a09 typo 2026-04-29 12:49:32 +02:00
793d32164e rename pdf to text 2026-04-28 23:56:37 +02:00
39a7317cc5 note: retitle gpg with vim 2026-04-28 19:58:46 +02:00
c06884d434 note: csv to markdown in vim 2026-04-28 18:11:54 +02:00
c25f55054b note: format markdown in vim 2026-04-28 18:01:52 +02:00
73f8dc0feb reformat tables 2026-04-28 17:40:08 +02:00
a4ffedcb6b note: place arch gpu required tags 2026-04-28 13:23:25 +02:00
b27ccb33ab note: how to send email 2026-04-28 02:10:39 +02:00
95b753549b note useage in lowdown.mk example 2026-04-27 17:20:35 +02:00
c586062552 git commit -p 2026-04-27 17:12:52 +02:00
0d25236b27 reword column examples 2026-04-27 17:12:29 +02:00
d53ca311c1 split shell tips into bash and shell 2026-04-27 17:08:41 +02:00
3a7a92de14 edit editors 2026-04-27 15:21:14 +02:00
53eba915b3 explain shell-like writing in readme 2026-04-27 13:35:27 +02:00
6a33521f33 edit shell tips 2026-04-27 13:35:22 +02:00
319ae8df79 clean up old formatting 2026-04-27 13:13:22 +02:00
ea4f44e096 clean up networking 2026-04-27 12:59:27 +02:00
1994d9fbb3 move git cleanup 2026-04-27 12:41:06 +02:00
cc811fc025 edit virtualization setup 2026-04-27 12:34:26 +02:00
c2f72aed84 only ignore db.rec 2026-04-27 12:26:43 +02:00
2e305b3604 clean up cmd tags 2026-04-27 12:02:33 +02:00
b2ded0008c cmd: git request-pull 2026-04-27 12:01:22 +02:00
43 changed files with 547 additions and 339 deletions

View File

@@ -5,6 +5,8 @@ PAGER ?= less -Ri
READER != command -v mdless bat glow less more pg | head -1
FZF != command -v fzf sk | head -1
markdown = $(wildcard */*.md */*/*.md)
ifeq "$(FZF)" ""
$(info Install fzf)
endif
@@ -40,7 +42,7 @@ include cmd.mk
printf '%s\n' '%type: wordcount int' >> $@
printf '%s\n\n' '%sort: wordcount' >> $@
.dbs/new.rec: $(wildcard */*.md */*/*.md) | .dbs/head.rec
.dbs/new.rec: $(markdown) | .dbs/head.rec
$(info Updating: $?)
grep -q guide $@ 2>/dev/null || cp $| $@
@-$(foreach entry, $?, \
@@ -68,6 +70,7 @@ include cmd.mk
sed '/^%/d' $^ | recsel -G path | recsel -U >> $@
default += db.rec
ignored += db.rec
db.rec: command.rec .dbs/notes.rec
recinf -d $< > $@
echo '' >> $@
@@ -75,7 +78,7 @@ db.rec: command.rec .dbs/notes.rec
$(info Making main database: $@)
.git/info/exclude: $(default)
.git/info/exclude: $(ignored)
@echo $^ | tr ' ' '\n' > $@
default += .git/info/exclude

View File

@@ -38,11 +38,6 @@ The output is a couple of lines of code, with changeable components as variables
alias rrc='$PAGER "$(find . -maxdepth 2 -name "*rc" | fzf)"'
```
### Guides
The notes are mostly written like a heavily commented script.
Most are setup guides.
### The Function
Running `make function` outputs a shell function which searches through this
@@ -133,6 +128,16 @@ grep ls --color=always $HISTFILE | $PAGER
Now we can see what can be changed.
### Aim to Script
Guides should read like a heavily commented script, so CLI commands are preferred to GUI commands.
- Bad: '*edit the file `.config/tspreed/tspreed.rc` and change `focuscolor` to '2'.*'
- Good: `sed -i '/focuscolor/s/=1/=2/' ~/.config/tspreed/tspreed.rc`
* `cat !$`
Despite being 'script-like', interactive bash commands like `cat !$` are still fine just to show how to double-check results when setting things up interactively.
### Show, Don't Tell
Articles should say what to type, not the output.

View File

@@ -41,7 +41,7 @@ Check your `~/.config/profanity/profrc` for how to data's saved.
## Automatically Sign In
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*

76
chat/send_email.md Normal file
View File

@@ -0,0 +1,76 @@
---
title: Send an email with a CLI command
tags:
- email
requires:
- data/pass.md
---
# Setup the Config
Install `msmtp` and set up the defaults.
```sh
mkdir ~/.config/msmtp/
cat > ~/.config/msmtp/config << EOF
defaults
tls on
auth on
EOF
```
You'll need to fill in some variables, like your provider's hostname and SMTP port.
The `${pass_name}` is just the `pass` command which gives your email password.
```sh
name=posteo
host=posteo.de
port=587
user=bob@posteo.net
pass_name=posteo.net
```
With those in, add that default account.
```sh
cat >> ~/.config/msmtp/config << EOF
account ${name}
host ${host}
port ${port}
user ${user}
from ${user}
passwordeval pass ${pass_name}
```
Finally, set this as the default account:
```sh
account default : ${account} >> ~/.config/msmtp/config
```
# Write an Email
Fill out the headers in a file called `mail`.
```
From: MSMTP ${user}
Subject: Pipes
To: ${recipient_name} <${recipient_email}>
A pipe gives a wise man time to think and a fool something to stick in his
mouth.
```
# Send
Send the email:
```sh
msmtp -t bindrpg@posteo.uk < mail
```

View File

@@ -10,27 +10,27 @@ shell: sh
bin: column
tag: format
aim: Reformat file with an explicit separator (`-s`)
aim: Reformat user accounts with an explicit separator (`-s`)
cmd: column -ts: /etc/passwd
shell: sh
bin: column
tag: format
aim: Sort lines into columns with names
aim: Sort user accounts into columns with names
cmd: column -ts: -N User,PW,UID,GID,Description,Home,shell -H PW,GID /etc/passwd
note: Hide some columns with `-H`.
shell: sh
bin: column
tag: format
aim: Sort lines into columns and reorder them
aim: Sort user accounts into columns and reorder them
cmd: column -ts: -N User,PW,UID,GID,Description,Home,shell -H PW,GID -O User,Description,shell /etc/passwd
note: Unspecified items remain.
shell: sh
bin: column
tag: format
aim: Output to json format with `-J`
aim: Output user accounts in json format with `-J`
cmd: column -J -ts: -H PW,GID,shell -N User,PW,UID,GID,Description,Home,shell /etc/passwd
shell: sh
bin: column
@@ -115,7 +115,6 @@ bin: ntpd
tag: time
tag: system
aim: Check a service
cmd: sudo systemctl status mpd
shell: sh
@@ -123,7 +122,6 @@ bin: systemd
tag: system
tag: service
aim: Recognize service changes
cmd: sudo systemctl daemon-reload
shell: sh
@@ -131,7 +129,6 @@ 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
@@ -140,7 +137,6 @@ 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
@@ -149,7 +145,6 @@ bin: systemd
tag: system
tag: boot
aim: See what the computer is doing
cmd: journalctl -f
shell: sh
@@ -188,7 +183,6 @@ shell: sh
bin: journalctl
tag: system
aim: Convert markdown table to csv
cmd: mlr --imarkdown --ocsv cat ${file}.md
bin: mlr
@@ -359,7 +353,6 @@ tag: vision
tag: video
shell: sh
aim: Convert video to audio
cmd: ffmpeg -i ${input}.mp4 -vn ${output}.mp3
bin: ffmpeg
@@ -375,7 +368,6 @@ bin: ffmpeg
tag: vision
shell: sh
aim: Change resolution
cmd: ffmpeg -i ${input}.mp4 -filter:v scale=1280:720 -c:a copy ${output}.mp4
bin: ffmpeg
@@ -437,6 +429,13 @@ cmd: urldecode() { echo -e "${@//%/\\x}"; }
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
bin: git
shell: sh
aim: Request a definition from the terminal.
cmd: word='abderian'
+ curl -s dict://dict.org/define:${word}:
@@ -453,3 +452,24 @@ tag: writing
tag: comfy
tag: dict
shell: sh
aim: Email a pull request which points to your git server
tag: git
bin: git
tag: email
tag: pr
cmd: repo=ssh://soft.dmz.rs:2222/mkdots/
+ theirHead='HEAD^^^^'
+ head=master
+ git request-pull "${theirHead}" "${repo}" "${head}"
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').
aim: Clean up a bloated git repo
cmd: git fsck --full
+ git gc --prune=now --aggressive
+ git repack
bin: git
tag: maintenance
shell: sh

View File

@@ -10,7 +10,7 @@ tags:
Combine many files and directories into a single t-archive file.
```sh
tar cf "$ARCHIVE".tar $DIR
tar cf "${archive}".tar ${dir}
```
You can remember this with the mnemonic '*C*reate *F*ile'.
@@ -18,13 +18,13 @@ Unfortunately, this stores the full file path, so making a tar archive of `/etc/
It's often better to tell tar which path to start from using the `-C` flag.
```sh
tar cf "$ARCHIVE".tar -C /etc/ nginx
tar cf "${archive}".tar -C /etc/ nginx
```
Check the contents of your archive with:
```sh
tar tf "$ARCHIVE".tar
tar tf "${archive}".tar
```
If you want to store 'everything in a directory', then using `*` will not work, because it will target everything in the *current* directory.
@@ -33,7 +33,7 @@ Instead, you can store the target in a variable:
```sh
files=$(ls /etc/nginx)
tar cf "$ARCHIVE".tar -C /etc/nginx/ $file
tar cf "${archive}".tar -C /etc/nginx/ $file
```
# Extract
@@ -41,7 +41,7 @@ tar cf "$ARCHIVE".tar -C /etc/nginx/ $file
Extract the tar archive with
```sh
tar xf "$ARCHIVE".tar
tar xf "${archive}".tar
```
You can remember this with the mnemonic 'e*X*tract *F*ile'.
@@ -51,7 +51,7 @@ You can remember this with the mnemonic 'e*X*tract *F*ile'.
Create a zip-compressed archive with the `z` flag.
```sh
tar czf "$ARCHIVE".tgz -C /etc/nginx/ $file
tar czf "${archive}".tgz -C /etc/nginx/ $file
```
You can use any file ending you want, but sane people like to use '.tgz' or '.tar.tgz'.

View File

@@ -1,22 +0,0 @@
---
title: Clean up a bloated git repo
tags:
- data
- setup
requires:
- data/git.md
---
```sh
git fsck --full
```
```sh
git gc --prune=now --aggressive
```
```sh
git repack
```

View File

@@ -132,7 +132,7 @@ Refreshing keys will tell you if some key you have contains a signature from som
gpg --refresh-keys
```
You can use the [crontab](../../system/cron.md) to refresh keys, but this will mostly fail, since keyservers often don't hold the right data.
You can use the [crontab](system/cron.md) to refresh keys, but this will mostly fail, since keyservers often don't hold the right data.
# Export

View File

@@ -1,5 +1,5 @@
---
title: Edit gpg encrypted files easily
title: Edit gpg encrypted files with vim
tags:
- vim
- data

View File

@@ -8,7 +8,7 @@ requires:
- data/gpg.md
---
Setup [gpg](gpg.md) keys.
Setup [gpg](data/gpg.md) keys.
Show your gpg secret it:
@@ -19,28 +19,37 @@ gpg --list-secret-keys
Then use the id number under `sec` to make a pass repo:
```sh
KEY="$(gpg --list-secret-keys | grep -m 1 -A1 '^sec' | tail -n 1)"
key="$(gpg --list-secret-keys | grep -m 1 -A1 '^sec' | tail -n 1)"
```
```sh
pass init $KEY
pass init $key
cat .password-store/.gpg-id
```
To add a basic password, e.g. for `$WEBSITE`:
To add a basic password, e.g. for `${website}`:
```sh
pass $WEBSITE
pass ${website}
```
To insert a multi-line password, e.g. with a login name:
```sh
pass add -m $WEBSITE
pass add -m ${website}
```
Remove a password:
```sh
pass rm $WEBSITE
pass rm ${website}
```
You can generate passwords with `xkcdpass`.
Automatically insert a password with `pass insert`:
```sh
xkcdpass | pass insert --echo ${website}
```

View File

@@ -1,5 +1,5 @@
---
title: pdf to txt
title: Convert a scanned pdf to text
tags:
- data
- pdf

View File

@@ -44,10 +44,11 @@ You might get it in the `apache` package or similar.
`htpasswd` allows you to generate passwords for users, and place them in `/etc/radicale/users`.
```sh
PASS="$(xkcdpass)"
htpasswd -nb $USER "$PASS" | sudo tee -a /etc/radicale/users
echo "Your username is $USER"
echo "Your password is $PASS"
pass="$(xkcdpass)"
username=alice
htpasswd -nb ${username} "${pass}" | sudo tee -a /etc/radicale/users
echo "Your username is ${username}"
echo "Your password is ${pass}"
```
Right now, you can't sign into the server except through the localhost, which is pointless.
So now we add a subdomain to `nginx`.
@@ -97,8 +98,8 @@ sudo ln -s /etc/nginx/sites-available/radicale /etc/nginx/sites-enables/
Finally, replace the example `DOMAIN` with your actual domain name.
```sh
DOMAIN=whatever.com
sudo sed -i "s/DOMAIN/$DOMAIN/g" /etc/nginx/sites-available/radicale
domain=whatever.com
sudo sed -i "s/DOMAIN/${domain}/g" /etc/nginx/sites-available/radicale
```
(optional: replace that `cal.` prefix with anything else)
@@ -111,7 +112,7 @@ sudo nginx -t
You will almost certainly need a new SSL certificate for the site:
```sh
sudo certbod -d cal.$DOMAIN
sudo certbod -d cal.${domain}
```
Start or restart both services:

View File

@@ -9,8 +9,6 @@ requires:
- writing/vim.md
---
- [Sample file](sc-im/sample.sc)
# Basic Commands
## See Cells

View File

@@ -26,7 +26,7 @@ Once you have the database, you can find nearly any file instantly.
- Search for jpg images with 'dog' or 'Dog' in the name: `locate -i dog jpg`
- Search for videos: `plocate --regex '.mp4$|.mkv$|.wmv$|.webm$|.mov$|.avi$'`
For best results, run `updatedb` regularly, perhaps in [crontab](../system/cron.md).
For best results, run `updatedb` regularly, perhaps in [crontab](system/cron.md).
## Search More Places

View File

@@ -41,7 +41,7 @@ git clone http://localhost:23232/${some_repo}.git
### `https` Setup
Put this file at `/etc/nginx/sites-enabled/$DOMAIN.tld`, then set up standard certificates with [nginx](../../networking/website/nginx.md).
Put this file at `/etc/nginx/sites-enabled/$DOMAIN.tld`, then set up standard certificates with [nginx](networking/nginx.md).
(replace `${DOMAIN_NAME}` with your domain's name).

View File

@@ -1,8 +1,10 @@
---
title: Ach Linux GPU Setup
title: Arch Linux GPU Setup
tags:
- arch
- GPU
requires:
- distros/arch/install_yay.md
---
# Step 1: Multilib

View File

@@ -54,9 +54,8 @@ brightnessctl s 10%-
brightnessctl s 10%+
```
# Other Tricks
# Related
- [autologin](autologin.md)
- [services](sv.md)
- [wifi](../../networking/wpa_supplicant.md)
- [autologin](distros/void/autologin.md)
- [services](distros/void/sv.md)

View File

@@ -83,7 +83,7 @@ content: # This data file was generated by the Spreadsheet Calculator Improvised
filename: lowdown.mk
bin: make
usage: {{bin}} -f {{filename}}
usage: {{bin}} -f {{filename}} example
content: output: all
+
+ .PHONY: example
@@ -120,3 +120,36 @@ content: output: all
+
+ clean :
+ rm -rf public html
filename: Makefile
bin: make
usage: make
content: ### Variables
+
+ PAGER ?= $(shell command -v mdless bat less | head -1 )
+ EDITOR ?= vi
+
+ requirements += lowdown
+
+ ### Dependencies
+
+ out: help
+
+ ### Patterns
+
+
+ ### Phonies
+
+ .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
+
+ .PHONY: check
+ check: ## Check you have the required dependencies
+ @$(foreach dep, $(requirements), type $(dep) >/dev/null || echo "Install $(dep)." ; )
+
+ .PHONY: clean
+ clean: ## Remove generated files.
+ $(RM) $(defaults)

View File

@@ -3,9 +3,10 @@ title: printers
tags:
- hardware
---
# Cups: The Common Unix Printing System
Configure cups at /etc/cups/supsd.conf, or visit the local webpage at http://localhost:631 if you want to use the Apple interface, otherwise, it's the printing daemon.
Configure cups at `/etc/cups/supsd.conf`, or visit the local webpage at http://localhost:631 if you want to use the Apple interface, otherwise, it's the printing daemon.
# The Printing Daemon

View File

@@ -12,7 +12,7 @@ tags:
| CNAME | Alternative Address | "$domain".rs, "$subdomain.$domain".com |
| NS | Nameserver | ns1.fastname.com |
| MX | Email server | "$domain".com |
| TXT | Literally anything,including ownership of a domain | - |
| TXT | Literally anything | "drunk giraffes can't spell" |
Query a host's IP and email handlers with the `host` command.

View File

@@ -3,6 +3,7 @@ title: rclone
tags:
- networking
- synch
- backup
---
The manpage's 'Synopsis' provides a fast reference.
```

View File

@@ -3,6 +3,7 @@ title: Download Website
tags:
- networking
- scraping
- web
---
```sh

View File

@@ -2,29 +2,30 @@
title: Download videos
tags:
- scraping
- video
---
Install `yt-dlp`.
```sh
yt-dlp --write-auto-sub *<URL>*
yt-dlp --write-auto-sub ${url}
```
It will default to English, but you can specify another language with the flag --sub-lang:
```sh
youtube-dl --sub-lang sv --write-auto-sub *<URL>*
youtube-dl --sub-lang sv --write-auto-sub ${url}
```
You can list all available subtitles with:
```sh
yt-dlp --list-subs *<URL>*
yt-dlp --list-subs ${url}
```
It's also possible to skip the video and only download the subtitle if you add the flag --skip-download:
```sh
yt-dlp --sub-lang sv --write-auto-sub --skip-download *<URL>*
yt-dlp --sub-lang sv --write-auto-sub --skip-download ${url}
```
## Alternative

View File

@@ -33,6 +33,7 @@ Then start that service:
```sh
sudo systemctl start sshd
```
Test it works by using ssh into your own system, from inside:
@@ -77,6 +78,7 @@ Look at your keys:
```sh
ls ~/.ssh
ls -l ~/.ssh
```
You can share the one ending in `.pub` freely.
@@ -86,6 +88,7 @@ Now send those keys to a remote computer:
```sh
ssh-copy-id ${username}@{ip_address}
ssh ${username}@{ip_address}
```
Now you can log in without a password.

View File

@@ -1,94 +0,0 @@
---
title: network
tags:
- networking
---
# Netstat Stuff
Stats on local net usage within domain.
```sh
iftop -p -n
```
```sh
whois domain.com
```
Info on domain, whether it's taken, et c.:
```sh
dig domain.com
```
```sh
ifconfig
```
Versatile wifi tool:
```sh
nmcli
```
# Examples
You want to connect to the internet.
```sh
sudo iwconfig
```
Get knowledge of wireless state. The output might be:
> wlp3s0 IEEE 802.11 ESSID:"Gandalf WajFaj"
> Mode:Managed Frequency:2.412 GHz Access Point: 10:05:01:90:AC:1A
> Bit Rate=144.4 Mb/s Tx-Power=15 dBm
> Retry short limit:7 RTS thr:off Fragment thr:off
> Encryption key:off
> Power Management:on
> Link Quality=64/70 Signal level=-46 dBm
> Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag
> Tx excessive retries:0 Invalid misc:363 Missed beacon
This tells you that your ESSID is 'Gandalf WajFaj', and the access point name is 10:05:......
```sh
nmcli radio
```
You get an overview of your radio devices.
You're told that eth0 deals with your ethernet and `wlan0` deals with wifi.
`wlan0` is a file which represents your wifi device.
```sh
nmcli wlan0 wifi rescan
```
```sh
nmcli device wifi list
```
Now to connect.
```sh
nmcli device wifi connect [SSID] [your password] [wifi password]
```
Alternatively, you can use
```sh
nmcli -ask device wifi connect [SSID]
```
And it'll ask for your password, so you're not typing it in in full view.

View File

@@ -4,10 +4,6 @@ tags:
- networking
- VPN
---
<!--
from
https://engineerworkshop.com/blog/how-to-set-up-wireguard-on-a-raspberry-pi/
-->
## On Server

View File

@@ -1,66 +0,0 @@
---
title: wireless
tags:
- networking
---
Check wifi's working
```sh
lspci -k
```
Or for usb wifi:
```sh
dmesg | grep usbcore
```
...and hopefully it'll say the new interface is registered.
Check if a wifi interface has been created
```sh
ip link
```
...or
```sh
iw dev
```
Assuming it's wlan0, bring it up with
```sh
ip link set wlan0 up
```
Error messages probably means your wireless chipset requires a firmware to function. In this case, check the kernel messages for firmware being loaded
```sh
dmesg | grep firmware
```
# Utilities
- `iw` doesn't do wpa/wpa2.
- `iwd` does everything except WEXT encryption.
- `wpa_supplicant` does everything.
# Connecting
Get the link status:
```sh
iw dev wlan0 link
```
Scan for available points:
```sh
iw dev wlan0 scan
```
The connecting commands do not cover wpa2.

70
shell/bash_tips.md Normal file
View File

@@ -0,0 +1,70 @@
---
title: Bash tips
tags:
- shell
- comfy
- bash
---
# This & That
Refer to 'that last thing', and 'the first thing':
```sh
fortune -l > file1
cat !$ | tr -d u > file2
cat file1 !$
diff !^ !$
```
**NB:** this can go wrong:
```sh
ls -l file1 file2
cat !^
```
**NB:** this only works when running `bash` interactively, never in scripts.
# Lists
You can put a list inside any `bash` argument, and `bash` will expand that part into a new argument.
```bash
echo file {one,two,three}.txt
echo file-{one,two,three}.txt
touch !$
```
Look at text files:
```bash
ls *.{txt,md}
```
Look at size of jpg or png files in the `img/` directory:
```bash
du img/*.{jpg,png}
```
# Automatic Lists
```bash
echo {a..d}
echo Archive_{B..E}
```
Using multiple lists works fine.
```bash
mkdir first second third
echo {first,second,third}/file_{1..3}.txt
x={first,second,third}/file_{1..3}.txt
echo $x
echo {first,second,third}/file_{1..3}.txt
x="$(!!)"
echo $x
for file in $x ; do fortune > $file ; done
```

View File

@@ -46,5 +46,5 @@ Just press `!`, e.g. `!ls`.
# Edit a File
While reading a file, press `v` to edit it ('v' stands of `vi`).
While reading a file, press `v` to edit it ('v' stands for `vi`).

View File

@@ -5,23 +5,6 @@ tags:
- comfy
---
# This & That
Refer to 'that last thing', and 'the first thing':
```sh
fortune -l > file1
cat !$ | tr -d u
diff !^ !$
```
**NB:** this can go wrong:
```sh
ls -l file1 file2
cat !^
```
# Done
`<C-d>`
@@ -29,9 +12,8 @@ cat !^
- If you have a command, Control + d will execute the command.
- If you have nothing, `exit`.
# Clear Search Highlights
# Search & Clear Highlights
`<Esc>+u`
Works in most programs with search.
You can search in many programs by using `/`.
Most programs let you clearn the highlighting with `<Esc>+u`.

View File

@@ -16,7 +16,7 @@ rdfind $dir
$EDITOR results.txt
```
Replace the duplicated files with [hard links](../basics/hard_links.md).
Replace the duplicated files with [hard links](system/hard_links.md).
```sh
rdfind -makehardlinks true $dir

View File

@@ -1,25 +1,25 @@
---
title: $EDITOR
title: Setting an EDITOR
tags:
- system
- defaults
---
The System's default text editor can be defined within /etc/profile. It's given the variable `EDITOR`.
Add these lines to `/etc/profile.d/custom.sh`:
Programs expect a default 'line EDITOR' and 'VISUAL editor' so they know how you want to edit text.
Add these lines to automatically set the variables in `bash`:
```sh
echo 'export EDITOR=vim' >> /etc/profile.d/custom.sh
echo 'export VISUAL=$EDITOR' >> /etc/profile.d/custom.sh
echo 'export EDITOR=vim' >> ~/.bashrc
echo 'export VISUAL=$EDITOR' >> ~/.bashrc
```
Then reload that profile with:
Make the change system-wide by adding them to `/etc/profile.d/custom.sh` instead, which is loaded at startup.
You can add a GUI editor as the `$VISUAL` editor:
```sh
source /etc/profile
VISUAL=gedit
```
If you want to ensure `nano` never appears again:
```sh
sudo ln -sf $(which vim) $(which nano)
```
To use a true line editor, as `$EDITOR`, see [ed][writing/ed.md].

View File

@@ -180,6 +180,6 @@ In this case, the makefile can see that `backup` depends on the current backup f
# The Rest
- [File patterns](makefiles/patterns.md)
- [Makefile graphs](makefiles/graph-easy.md)
- [In-build help](makefiles/help.md)
- [File patterns](system/makefiles/patterns.md)
- [Makefile graphs](system/makefiles/graph-easy.md)
- [In-build help](system/makefiles/help.md)

View File

@@ -5,7 +5,7 @@ tags:
- make
---
Using the [basic example](../makefiles.md), you can make a complete backup of all backup files.
Using the [basic example](system/makefiles.md), you can make a complete backup of all backup files.
This file will depend upon everything inside the `$(storage_directory)`.
Unlike `bash`, you can't just say `storage_directory/*`: the pattern must be stated as a 'wildcard'.

View File

@@ -24,11 +24,11 @@ Note the asterisk marking the boot partition.
# IDs
| ID | Meaning |
|----|:--------|
|83 |Linux |
| 5 |Extended |
| 82 |Swap |
| ID | Meaning |
|:----------:|:-----------|
| 83 | Linux |
| 5 | Extended |
| 82 | Swap |
fdisk will not help with a GPT formatted drive. For this, use gdisk, which is mostly the same.
@@ -52,15 +52,15 @@ mkreiserfs /dev/sdc2
# File System Types
| Type | Advantages | Disadvantages |
|------|:-----------|:--------------|
|ext2 | |No journaling means that the file offers no crash recovery.
|ext3 | Journaling |
|ext4 | Journaling and handles files of up to 16TB.|
|reiserfs| Journalin and stable.|
|btrfs |Reliable and stable|
|XFS |Journaling, great for large files.|
|VFAT |Comptable with Windows, like FAT32|
| Type | Advantages | Disadvantages |
|----------------|:----------------------------------------------|:-------------------------------------------------------------|
| ext2 | | No journaling means that the file offers no crash recovery. |
| ext3 | Journaling | |
| ext4 | Journaling and handles files of up to 16TB. | |
| reiserfs | Journalin and stable. | |
| btrfs | Reliable and stable | |
| XFS | Journaling, great for large files. | |
| VFAT | Comptable with Windows, like FAT32 | |
# Parted

View File

@@ -13,23 +13,23 @@ Input a command with C-b
In addition to Windows, there are panes.
|Commands | Key |
| ---- | ---- |
| New Window | c |
| Previous Window | p |
| next window | n |
| list windows | w |
| vertical split | % |
| horizontal split | " |
| name a command | : |
| kill pane | x |
| kill session | d |
|Commands | Key |
|------------------|------|
| New Window | c |
| Previous Window | p |
| next window | n |
| list windows | w |
| vertical split | % |
| horizontal split | " |
| name a command | : |
| kill pane | x |
| kill session | d |
|Name Commands|
| --------|
| split-window |
| rename-window |
### Name Commands
- split-window
- rename-window
# Sessions

View File

@@ -1,21 +1,19 @@
---
title: Docker
title: Setup Docker
tags:
- documentation
- virtualization
- setup
- containers
requires:
- system/groups.md
---
Install docker, add your user to the docker group, and start the service.
```sh
sudo pacman -S docker
```
```sh
sudo usermod -aG docker $USER
```
```sh
sudo su $USER
sudo systemctl start docker
```
@@ -69,9 +67,9 @@ docker rm 97796727e883
# Networking
Get a list of docker container ips
Get a list of docker container IPs
```sh
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' *container_name_or_id*
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${name}
```

View File

@@ -1,11 +1,12 @@
---
title: virtualbox
title: Setup Virtualbox
tags:
- system
- setup
- virtualization
requires:
- system/groups.md
---
# Setup
Load the modules (or just reboot):

View File

@@ -12,14 +12,6 @@ Turn a markdown file into a pdf:
lowdown -stms "$FILE".md | pdfroff -itk -mspdf > "$FILE".pdf
```
*Example:* put [this Makefile](lowdown/example.txt) in a directory, rename it `Makefile`, then do:
```sh
make example
make
```
To give the document a title, put that title in the metadata:
```sh

View File

@@ -3,8 +3,13 @@ title: Ed: The Standard Editor
tags:
- writing
- guide
- sed
- vim
---
Understanding `ed` will let you understand all that feels strange about the system.
It set the standards for `sed` and `vi`.
`ed` was designed for real terminals, i.e. a typewriter.
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.
@@ -12,7 +17,6 @@ A silent machine meant a happy machine.
To fully appreciate `ed`, you can slow down your terminal with the following command:
```sh
ff=/tmp/bashpipe
mkfifo $ff
@@ -24,7 +28,6 @@ Try running `dir` and `dir -F`!
Okay, now onto `ed`...
# Basic Usage
Open a file:
@@ -67,11 +70,8 @@ Delete the current line:
d
```
Write the 'buffer' to disk:
```ed
w
```
@@ -86,7 +86,6 @@ q
Open that file:
```ed
ed file.md
```

View File

@@ -25,3 +25,4 @@ Keybind to exit this mode is `Ctrl+q`
- [Completion](vim/completion.md)
- [Window Splits](vim/windows.md)
- [Use vim bindings in bash](vim/vim_in_bash.md)
- [A game to learn how to code in Vim](https://www.vim-hero.com/)

116
writing/vim/csv_to_md.md Normal file
View File

@@ -0,0 +1,116 @@
---
title: CSV to Markdown in Vim
tags:
- writing
- vim
- csv
- markdown
requires:
- writing/vim.md
---
Open a CSV table (I made this one with `:r!sed 's/:/,/g' /etc/passwd | head`).
```csv
root,x,0,0,,/root,/bin/bash
bin,x,1,1,,/,/usr/bin/nologin
daemon,x,2,2,,/,/usr/bin/nologin
mail,x,8,12,,/var/spool/mail,/usr/bin/nologin
ftp,x,14,11,,/srv/ftp,/usr/bin/nologin
http,x,33,33,,/srv/http,/usr/bin/nologin
nobody,x,65534,65534,Nobody,/,/usr/bin/nologin
dbus,x,81,81,System Message Bus,/,/usr/bin/nologin
systemd-coredump,x,981,981,systemd Core Dumper,/,/usr/bin/nologin
systemd-network,x,980,980,systemd Network Management,/,/usr/bin/nologin
```
Highlight the table.
- Go to the top, with 'root'.
- Type `V9j`.
- `:!column -ts, -o '|'`
- Return!
```csv
root |x|0 |0 | |/root |/bin/bash
bin |x|1 |1 | |/ |/usr/bin/nologin
daemon |x|2 |2 | |/ |/usr/bin/nologin
mail |x|8 |12 | |/var/spool/mail|/usr/bin/nologin
ftp |x|14 |11 | |/srv/ftp |/usr/bin/nologin
http |x|33 |33 | |/srv/http |/usr/bin/nologin
nobody |x|65534|65534|Nobody |/ |/usr/bin/nologin
dbus |x|81 |81 |System Message Bus |/ |/usr/bin/nologin
systemd-coredump|x|981 |981 |systemd Core Dumper |/ |/usr/bin/nologin
systemd-network |x|980 |980 |systemd Network Management|/ |/usr/bin/nologin
```
The command displays as `:'<,'>!column -ts, -o '|'`.
This looks better, but the spacing is bad because the output separate is `-o '|'`.
You can put spaces around that pipe by making the separator a pipe (`-s'|'`)
and making the output separator a pipe with spaces (`-o' | '`).
```vim
:'<,'>!column -ts'|' -o ' | '
```
```csv
root | x | 0 | 0 | | /root | /bin/bash
bin | x | 1 | 1 | | / | /usr/bin/nologin
daemon | x | 2 | 2 | | / | /usr/bin/nologin
mail | x | 8 | 12 | | /var/spool/mail | /usr/bin/nologin
ftp | x | 14 | 11 | | /srv/ftp | /usr/bin/nologin
http | x | 33 | 33 | | /srv/http | /usr/bin/nologin
nobody | x | 65534 | 65534 | Nobody | / | /usr/bin/nologin
dbus | x | 81 | 81 | System Message Bus | / | /usr/bin/nologin
systemd-coredump | x | 981 | 981 | systemd Core Dumper | / | /usr/bin/nologin
systemd-network | x | 980 | 980 | systemd Network Management | / | /usr/bin/nologin
```
Make a header by copying the top line and replacing text (`yypkR`).
That's nicer, but the formatting's wrong again.
```markdown
User | Passwords | UID | GID | Description | Home | Shell
root | x | 0 | 0 | | /root | /bin/bash
[...]
```
Time to fix it with `:'<,'>!column -ts'|' -o'|'`.
```csv
User | Passwords | UID | GID | Description | Home | Shell
----------------- | ----------- | ------- | ------- | ---------------------------- | ----------------- | ----------
root | x | 0 | 0 | | /root | /bin/bash
bin | x | 1 | 1 | | / | /usr/bin/nologin
daemon | x | 2 | 2 | | / | /usr/bin/nologin
mail | x | 8 | 12 | | /var/spool/mail | /usr/bin/nologin
ftp | x | 14 | 11 | | /srv/ftp | /usr/bin/nologin
http | x | 33 | 33 | | /srv/http | /usr/bin/nologin
nobody | x | 65534 | 65534 | Nobody | / | /usr/bin/nologin
dbus | x | 81 | 81 | System Message Bus | / | /usr/bin/nologin
systemd-coredump | x | 981 | 981 | systemd Core Dumper | / | /usr/bin/nologin
systemd-network | x | 980 | 980 | systemd Network Management | / | /usr/bin/nologin
```
Now we just need the spacer line.
Copy the top line (`yyp`) and replace (`:s/not-pipe/-/g`).
You can say 'not the pipe symbol' with `[^|]` or 'not-pipe-or-colon' with `[^:|]`.
```vim
:s/[^:|]/-/g
```
# Keyboard Shortcut
Put this in your `~/.vimrc` to map 'Control + s' to reformat CSV while in visual mode.
```vim
vmap <C-s> :!column -ts, -o " \| "<Enter>yyp:s/[^\|:]/-/g<Enter>
```

82
writing/vim/format_md.md Normal file
View File

@@ -0,0 +1,82 @@
---
title: Reformat a Markdown Table
tags:
- writing
- vim
- markdown
requires:
- writing/vim.md
---
This markdown table is badly messed up:
```markdown
| File | Category |
|:------|:---------|
| calendar.md | tex|
| tex_packages.md | tex|
| completion.md | vim|
| csv_to_md.md | vim|
| format_md.md | vim|
```
Highight from the top with `V6j`, then run `column` to fix the output:
```vim
:!column -ts'|' -o '|'
```
It displays like this:
```vim
:'<,'>!column -ts'|' -o '|'
```
```markdown
| File | Category |
|:------ |:---------|
| calendar.md | tex |
| tex_packages.md | tex |
| completion.md | vim |
| csv_to_md.md | vim |
| format_md.md | vim |
```
That's better, but the header is broken.
Fix is by replacing spaces with dashes.
```vim
:s/ /-/g
```
The lines have too much whitespace.
You can fix this with the 'truncate' command, to squeeze repeating spaces or dashes.
```vim
tr -s ' -' |column -ts '|' -o '|'
```
```markdown
| File | Category |
|:----------------|:---------|
| calendar.md | tex |
| tex_packages.md | tex |
| completion.md | vim |
| csv_to_md.md | vim |
| format_md.md | vim |
```
# Keyboard Shortcut
Put this in your `~/.vimrc` to map 'Control + t' to reformat markdown tables in visual mode.
```vim
vmap <C-t> :!tr -s ' -' \|column -ts '\|' -o '\|'<Enter>j:s/ /-/g<Enter>k
```