Compare commits
10 Commits
b27ccb33ab
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
68734cfd1b
|
|||
|
019736de05
|
|||
|
76be2fbd3c
|
|||
|
34ef924a09
|
|||
|
793d32164e
|
|||
|
39a7317cc5
|
|||
|
c06884d434
|
|||
|
c25f55054b
|
|||
|
73f8dc0feb
|
|||
|
a4ffedcb6b
|
4
Makefile
4
Makefile
@@ -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, $?, \
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
title: Edit gpg encrypted files easily
|
||||
title: Edit gpg encrypted files with vim
|
||||
tags:
|
||||
- vim
|
||||
- data
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
title: pdf to txt
|
||||
title: Convert a scanned pdf to text
|
||||
tags:
|
||||
- data
|
||||
- pdf
|
||||
|
||||
@@ -9,8 +9,6 @@ requires:
|
||||
- writing/vim.md
|
||||
---
|
||||
|
||||
- [Sample file](sc-im/sample.sc)
|
||||
|
||||
# Basic Commands
|
||||
|
||||
## See Cells
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
33
example.rec
33
example.rec
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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`).
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
116
writing/vim/csv_to_md.md
Normal 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
82
writing/vim/format_md.md
Normal 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
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user