A collection of housekeeping tools to manage files and folders, set permissions, combine and crop PDF files — packaged as a single hk binary written in Rust.
hk — housekeeping tools
usage: hk <command> [argument]
commands:
cmbi combine all PDF files in the current folder
cmbs combine PDF files per subfolder
crop crop PDF header/footer (--top/--bott N inches, default 1.0)
fffp [--yes] [--all]
fix permissions: dirs 755, files 644 (keeps +x, skips private)
sffn sanitise folder and file names
help show this help
crop can take more than one pdf file, e.g.,
hk crop --top 1.5 --bott 0.5 file-1.pdf file-2.pdf ... file-n.pdfFor a single file, the command can simply be:
hk crop --top 1.5 --bott 0.5 file.pdfDownload the archive for your system from Releases, extract it, and put hk (or hk.exe) somewhere on your PATH:
| system | archive |
|---|---|
| Windows (x86-64) | hk-<version>-windows-x86_64.zip |
| macOS (Apple silicon, M-series) | hk-<version>-macos-arm64.tar.gz |
| Raspberry Pi 5 (64-bit Pi OS/Linux) | hk-<version>-linux-arm64-rpi5.tar.gz |
| Linux x86-64 (any distro) | hk-<version>-linux-x86_64.tar.gz |
The binaries are not code-signed or notarized, so macOS will block hk on first run. Before overriding that, verify the download (see releases), then clear the quarantine flag: xattr -d com.apple.quarantine hk.
For macOS (Apple silicon) and Linux (x86-64, arm64), a bash install script inst.sh is provided. It detects the OS and CPU it runs on, and does the following:
- Downloads the latest release for that system
- Verifies the download against its hash in
SHA256SUMS.txt - If the hash matches, extracts the
hkbinary (otherwise stops) - Clears the quarantine flag (macOS only)
- Installs
hkto/usr/local/bin(usessudoif needed)
Run it as follows from a terminal (be sure to check the script, if unsure):
curl --proto '=https' --tlsv1.2 -sSfL https://raw.githubusercontent.com/ckunte/hk/refs/heads/master/inst.sh | bashRust is required to build hk. Install it via rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shThen, from a clone of this repository, build and install the binary:
cargo install --path . --lockedAfter that, hk <command> is available anywhere.
None — hk is a single self-contained binary.
cmbiandcmbsuse pure Rust (lopdf) — no Ghostscript needed for combining PDFs. Re-running them replaces the previous*-comb.pdfwithout merging it into itself; the output is written atomically, inputs over 1 GiB or malformed files are reported as errors, andcmbscarries on past a failing foldersffnskips any rename whose target already exists, and reports itsffnsanitises folder names and the names of document (pdf, doc/docx, typ, xls/xlsx, ppt/pptx, odt/ods/odp, rtf, txt, md, csv, epub, pages/numbers/key), image (jpg, png, gif, webp, heic, tiff, bmp, svg), audio (mp3, wav, flac, m4a, aac, ogg) and video (mp4, mov, mkv, avi, webm, m4v) files natively — no fd, detox, or rename needed. Other files and hidden files are left alone. The list isSANITISE_EXTSinsrc/main.rsfffpis pure Rust — no shell tools needed (macOS / Linux only; not available on Windows). It asks for confirmation (--yesto skip), refuses to run in/or your home folder, keeps the executable bit on files that already have it (755), and skips private entries with no group/other access (such as 600 keys) unless you pass--all
Release archives are built from a tagged commit, listed with checksums in SHA256SUMS.txt, and carry signed build provenance. Verify a download with:
gh attestation verify hk-<version>-<system>.tar.gz --repo ckunte/hkp