Copy margin.py onto your PATH as margin, then: git config --global alias.cm '!git commit -m "$(margin)"'

Margin Bell

margin reads one line from the keyboard and writes it to standard output when you press Return. While you type, the terminal bell rings five characters before the margin, once at it, and on every key past it. Nothing is counted on screen and nothing is cut. Its input is what a person types, or pastes, into a real terminal; with no terminal it passes one line from stdin through unchanged. From this folder, run ./margin.py or uv run margin.py, and ./margin.py 50 for a margin of 50. For a commit subject: git commit -m "$(./margin.py)". With the alias above, the whole gesture is git cm.

Where the line goes: the subject of git log --oneline, the Subject: header of git format-patch, the lines of git shortlog. The margin is set for the copies.

Parts

  1. Margin stop (WIDTH, default 72).
  2. Margin bell (5 before the stop).
  3. Carriage return (Return).
  4. Line release (Ctrl-C).

Backspace, Ctrl-U (whole line) and Ctrl-W (last word) also work. Arrow keys, Esc and Tab do nothing. Ctrl-D on an empty line leaves with nothing.

To check the bell: margin --ring. The bell must be enabled in the terminal, or nothing will be heard. Under tmux it passes through with the defaults (bell-action any, visual-bell off). --flash sends the same signal as a brief reverse of the screen.

It counts characters, not bytes: an accented letter is one, a combining mark is none, a wide character is one.

The 5 is a choice, not a measurement.

Exit status: 0 line delivered, 1 no input, 2 usage error, 130 withdrawn.

Checks: uv run python -m unittest test_margin.py (they need git and tmux; run so far on Linux).

Colophon

Set in the terminal's own typeface. Bell not included. The 72 is the line of the Teletype Model 33 and the wrap in Tim Pope's 2008 note on commit messages.

normal is dead

Files