https://github.com/ficd0/mail-utils
Mirrored from https://git.sr.ht/~ficd/mail-utils
https://github.com/ficd0/mail-utils
Last synced: 11 months ago
JSON representation
Mirrored from https://git.sr.ht/~ficd/mail-utils
- Host: GitHub
- URL: https://github.com/ficd0/mail-utils
- Owner: ficd0
- License: mit
- Created: 2025-04-09T22:44:45.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-25T20:33:29.000Z (about 1 year ago)
- Last Synced: 2025-07-22T04:35:22.568Z (11 months ago)
- Language: Python
- Homepage: https://git.sr.ht/~ficd/mail-utils
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# email utils
This repository is part of my
[utilities collection](https://sr.ht/~ficd/utils/). It contains scripts that
improve the experience of reading and writing email with aerc and Helix.
| Script | Purpose |
| --------------------- | ------------------------------------------------------------------------------------ |
| `format.py` | Reflow and hard-wrap emails, preserving quotes, code blocks, lists, and indentation. |
| `paste-attachment.sh` | Utility for attaching files to emails in `aerc` from the user clipboard. |
## Format
By default, this script accepts its input on `stdin` and prints to `stdout`.
This makes it well suited for use with an editor like Helix. It has no
dependencies besides the standard Python interpreter, and was written and tested
against Python 3.13.2.
**Features:**
- Wraps emails at specified columns.
- Automatically reflows paragraphs.
- Squashes consecutive paragraph breaks.
- Preserves:
- Any long word not broken by spaces (e.g. URLs, email addresses).
- Quoted lines.
- Indented lines.
- Lists.
- Markdown-style code blocks.
- Usenet-style signature block at EOF.
- Sign-offs.
**Usage:**
```
usage: format.py [-h] [-w WIDTH] [-b] [--no-replace-whitespace] [--no-reflow]
[--no-signoff] [--no-signature] [--no-squash] [-i INPUT] [-o OUTPUT]
Formatter for plain text email.
"--no-*" options are NOT passed by default.
options:
-h, --help show this help message and exit
-w, --width WIDTH Text width for wrapping. (default: 74)
-b, --break-long-words
Break long words while wrapping. (default: False)
--no-replace-whitespace
Don't normalize whitespace when wrapping.
--no-reflow Don't reflow lines.
--no-signoff Don't preserve signoff line breaks.
--no-signature Don't preserve signature block.
--no-squash Don't squash consecutive paragraph breaks.
-i, --input INPUT Input file. (default: STDIN)
-o, --output OUTPUT Output file. (default: STDOUT)
```
## Paste Attachment
This script is meant to be used with `aerc`'s `:menu` and `:attach` command.
Please see the example below:
```ini
p = :menu -c 'paste-attachment.sh' :attach # Paste attachment
```
The above command will call the script in an embedded terminal through which you
may interact with it. You will be prompted for confirmation before any files are
written or attached to the email.
When invoked, it will query the user's clipboard via `wl-clipboard` If the type
is _not_ `text/plain`, the script will try to guess its extension and prompt the
user for a filename. The file will be written to a temporary directory and its
path printed to `stdout`.
If the clipboard contains `text/plain` that is a valid file path in either UNIX
or URI format, the script will process the path and print it to `stdout` in a
format `aerc` will accept.