Disposable workspace directories
  • Shell 75.4%
  • Nix 24.6%
Find a file
2026-05-15 23:16:08 +02:00
bin Add initial implementation 2026-05-11 07:16:19 +02:00
lib Remove empty workspaces instead of archiving 2026-05-15 22:56:10 +02:00
modules Add HomeManager and NixOS modules 2026-05-15 20:11:07 +00:00
tests Remove empty workspaces instead of archiving 2026-05-15 22:56:10 +02:00
.gitignore Add initial implementation 2026-05-11 07:16:19 +02:00
AGENTS.md Add AGENTS.md with notes for coding agents 2026-05-15 23:16:08 +02:00
flake.lock Add initial implementation 2026-05-11 07:16:19 +02:00
flake.nix Add HomeManager and NixOS modules 2026-05-15 20:11:07 +00:00
LICENSE Add license 2026-05-11 07:17:20 +02:00
README.md Remove empty workspaces instead of archiving 2026-05-15 22:56:10 +02:00

scratchpad

Disposable workspace directories.

What it does

scratchpad creates a fresh, uniquely-named working directory (e.g. amber-maple), drops you into an interactive shell — or runs the command you give it — inside that directory, and when the session exits moves the directory into an archive under a timestamped name.

It's meant for throwaway sessions whose output you might still want later: quick experiments, scratch builds, ad-hoc scripts, "let me just try something" moments. Files are never lost to a cd /tmp && rm -rf, but they also never clutter your home.

Try it

nix run git+https://repo.ciiol.net/ciiol/scratchpad
nix run git+https://repo.ciiol.net/ciiol/scratchpad -- sh -c 'echo hi > note.txt'

Install

Add the flake as an input:

inputs.scratchpad.url = "git+https://repo.ciiol.net/ciiol/scratchpad";

NixOS

{ inputs, ... }: {
  imports = [ inputs.scratchpad.nixosModules.default ];
  programs.scratchpad.enable = true;
}

home-manager

{ inputs, ... }: {
  imports = [ inputs.scratchpad.homeModules.default ];
  programs.scratchpad.enable = true;
}

The home-manager module exposes optional path knobs that render ~/.config/scratchpad/config.sh. Environment variables still override anything the module writes.

Option Purpose
programs.scratchpad.package Override the scratchpad package (defaults to this flake's build).
programs.scratchpad.activeDir Override where running workspaces live.
programs.scratchpad.archiveDir Override where finished workspaces are moved.
programs.scratchpad.lockDir Override the lock-file directory.

Supported systems: x86_64-linux, aarch64-linux, aarch64-darwin.

Usage

scratchpad                          # interactive shell in a new workspace
scratchpad python                   # run a command, archive it at the end

While the session is running, the workspace lives under $SCRATCHPAD_ACTIVE_DIR/<name>. When the shell or command exits — including on Ctrl-C or SIGTERM — the directory is moved to $SCRATCHPAD_ARCHIVE_DIR/<YYYY-MM-DD-HHMMSS>-<name>/. Workspaces that exit completely empty are removed instead of archived. The exit code of the inner command is propagated to the caller.

Configuration

All settings have sensible defaults; override them with environment variables or by creating ~/.config/scratchpad/config.sh. Environment variables take precedence over the config file.

Variable Default Purpose
SCRATCHPAD_ACTIVE_DIR $XDG_DATA_HOME/scratchpad/active (≈ ~/.local/share/scratchpad/active) Where running workspaces live
SCRATCHPAD_ARCHIVE_DIR $XDG_DATA_HOME/scratchpad/archive (≈ ~/.local/share/scratchpad/archive) Where finished workspaces are moved
SCRATCHPAD_LOCK_DIR $XDG_RUNTIME_DIR/scratchpad/locks (falls back under /tmp) Lock files
SCRATCHPAD_CONFIG $XDG_CONFIG_HOME/scratchpad/config.sh Path to the optional config file

Example ~/.config/scratchpad/config.sh:

# Keep archives on a larger disk
SCRATCHPAD_ARCHIVE_DIR="$HOME/work/scratchpad/archive"

License

Apache-2.0. See LICENSE.