Compare commits

...

6 Commits

Author SHA1 Message Date
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
7 changed files with 175 additions and 42 deletions

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 bin: column
tag: format tag: format
aim: Reformat file with an explicit separator (`-s`) aim: Reformat user accounts with an explicit separator (`-s`)
cmd: column -ts: /etc/passwd cmd: column -ts: /etc/passwd
shell: sh shell: sh
bin: column bin: column
tag: format 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 cmd: column -ts: -N User,PW,UID,GID,Description,Home,shell -H PW,GID /etc/passwd
note: Hide some columns with `-H`. note: Hide some columns with `-H`.
shell: sh shell: sh
bin: column bin: column
tag: format 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 cmd: column -ts: -N User,PW,UID,GID,Description,Home,shell -H PW,GID -O User,Description,shell /etc/passwd
note: Unspecified items remain. note: Unspecified items remain.
shell: sh shell: sh
bin: column bin: column
tag: format 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 cmd: column -J -ts: -H PW,GID,shell -N User,PW,UID,GID,Description,Home,shell /etc/passwd
shell: sh shell: sh
bin: column bin: column
@@ -429,6 +429,13 @@ cmd: urldecode() { echo -e "${@//%/\\x}"; }
tag: web tag: web
shell: bash 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. aim: Request a definition from the terminal.
cmd: word='abderian' cmd: word='abderian'
+ curl -s dict://dict.org/define:${word}: + curl -s dict://dict.org/define:${word}:

View File

@@ -83,7 +83,7 @@ content: # This data file was generated by the Spreadsheet Calculator Improvised
filename: lowdown.mk filename: lowdown.mk
bin: make bin: make
usage: {{bin}} -f {{filename}} usage: {{bin}} -f {{filename}} example
content: output: all content: output: all
+ +
+ .PHONY: example + .PHONY: example

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

@@ -5,25 +5,6 @@ tags:
- comfy - 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 !^
```
**NB:** this only works when running `bash` interactively, never in scripts.
# Done # Done
`<C-d>` `<C-d>`

View File

@@ -1,25 +1,25 @@
--- ---
title: $EDITOR title: Setting an EDITOR
tags: tags:
- system - 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 ```sh
echo 'export EDITOR=vim' >> /etc/profile.d/custom.sh echo 'export EDITOR=vim' >> ~/.bashrc
echo 'export VISUAL=$EDITOR' >> /etc/profile.d/custom.sh 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 ```sh
source /etc/profile VISUAL=gedit
``` ```
If you want to ensure `nano` never appears again: To use a true line editor, as `$EDITOR`, see [ed][writing/ed.md].
```sh
sudo ln -sf $(which vim) $(which nano)
```

View File

@@ -3,8 +3,13 @@ title: Ed: The Standard Editor
tags: tags:
- writing - writing
- guide - 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. `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. 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.
@@ -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: To fully appreciate `ed`, you can slow down your terminal with the following command:
```sh ```sh
ff=/tmp/bashpipe ff=/tmp/bashpipe
mkfifo $ff mkfifo $ff
@@ -24,7 +28,6 @@ Try running `dir` and `dir -F`!
Okay, now onto `ed`... Okay, now onto `ed`...
# Basic Usage # Basic Usage
Open a file: Open a file:
@@ -67,11 +70,8 @@ Delete the current line:
d d
``` ```
Write the 'buffer' to disk: Write the 'buffer' to disk:
```ed ```ed
w w
``` ```
@@ -86,7 +86,6 @@ q
Open that file: Open that file:
```ed ```ed
ed file.md ed file.md
``` ```