|
1 | | -# commit-editor |
| 1 | +# Commit Editor |
| 2 | + |
| 3 | +[](https://pypi.python.org/pypi/commit-editor) |
| 4 | +[](https://pypi.python.org/pypi/commit-editor) |
| 5 | +[](https://github.com/mprpic/commit-editor/blob/main/LICENSE) |
| 6 | +[](https://github.com/mprpic/commit-editor/actions) |
| 7 | + |
| 8 | +An opinionated, terminal-based text editor for git commit messages, built |
| 9 | +with [Textual](https://textual.textualize.io/). |
| 10 | + |
| 11 | +- **Title length warning**: Characters beyond position 50 on the first line are highlighted in red |
| 12 | +- **Auto-wrap body text**: Lines in the commit body (line 3+) are automatically wrapped at 72 characters (except for |
| 13 | + long strings that can't be wrapped, such as URLs) |
| 14 | +- **White space**: Trailing white space is automatically stripped when a file is saved; an empty newline is inserted |
| 15 | + at the end of the file if not present. |
| 16 | +- **Signed-off-by toggle**: Quickly add or remove a `Signed-off-by` trailer with a keyboard shortcut |
| 17 | +- **Status bar**: Shows current cursor position (line/column) and title length with warnings |
| 18 | + |
| 19 | +## Installation |
| 20 | + |
| 21 | +```bash |
| 22 | +# Using uv |
| 23 | +uv tool install commit-editor |
| 24 | + |
| 25 | +# Using pip |
| 26 | +pip install commit-editor |
| 27 | +``` |
| 28 | + |
| 29 | +### Requirements |
| 30 | + |
| 31 | +- Python 3.11 or later |
| 32 | +- Git (for Signed-off-by functionality) |
| 33 | + |
| 34 | +## Usage |
| 35 | + |
| 36 | +Configure `commit-editor` as your default git commit message editor: |
| 37 | + |
| 38 | +```bash |
| 39 | +git config --global core.editor commit-editor |
| 40 | +``` |
| 41 | + |
| 42 | +When you run `git commit`, the editor will open automatically. |
| 43 | + |
| 44 | +`commit-editor` can also be used as a standalone tool with: |
| 45 | + |
| 46 | +```bash |
| 47 | +commit-editor path/to/file.txt |
| 48 | +``` |
| 49 | + |
| 50 | +## Keyboard Shortcuts |
| 51 | + |
| 52 | +| Shortcut | Action | |
| 53 | +|----------|------------------------------| |
| 54 | +| `Ctrl+S` | Save the file | |
| 55 | +| `Ctrl+Q` | Quit | |
| 56 | +| `Ctrl+O` | Toggle Signed-off-by trailer | |
| 57 | + |
| 58 | +## Commit Message Format |
| 59 | + |
| 60 | +This editor enforces the widely-accepted git commit message conventions: |
| 61 | + |
| 62 | +1. **Title (line 1)**: Should be 50 characters or less; characters beyond 50 are highlighted in red as a warning. |
| 63 | + |
| 64 | +2. **Blank line (line 2)**: Separates the title from the body. |
| 65 | + |
| 66 | +3. **Body (line 3+)**: Should wrap at 72 characters; long lines are wrapped automatically as you type. |
| 67 | + |
| 68 | +## License |
| 69 | + |
| 70 | +MIT |
0 commit comments