Skip to content

Commit 48fa2fb

Browse files
committed
docs(commit): add preview to doc
1 parent 4a825e0 commit 48fa2fb

File tree

3 files changed

+92
-64
lines changed

3 files changed

+92
-64
lines changed

docs/commands/commit.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,26 @@ cz commit -l 72 # Limits message length to 72 characters
6060
!!! note
6161
The length limit only applies to the first line of the commit message. For conventional commits, this means the limit applies from the type of change through the subject. The body and footer are not counted.
6262

63+
### Live Subject Preview
64+
65+
Enable a live preview of your commit *subject* while you are typing with `cz commit --preview`:
66+
67+
```sh
68+
cz commit --preview
69+
```
70+
71+
You can also turn it on via configuration by setting:
72+
73+
```toml
74+
preview = true
75+
```
76+
77+
![Live subject preview](../images/cli_interactive/commit_preview.gif)
78+
79+
When `--preview` is enabled, the bottom toolbar always shows a live character counter while you type. With `-l/--message-length-limit`, the counter switches to `current/max chars`, and input is validated against the same first-line subject length rules.
80+
81+
![Live subject preview with length limit](../images/cli_interactive/commit_preview_length_limit.gif)
82+
6383
## Technical Notes
6484

6585
For platform compatibility, the `commit` command disables ANSI escaping in its output. This means pre-commit hooks coloring will be deactivated as discussed in [commitizen-tools/commitizen#417](https://github.com/commitizen-tools/commitizen/issues/417).

docs/config/configuration_file.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ All formats support the same configuration options. Choose the format that best
7676
retry_after_failure = false
7777
allow_abort = false
7878
message_length_limit = 0
79+
preview = false
7980
allowed_prefixes = [
8081
"Merge",
8182
"Revert",
@@ -134,6 +135,7 @@ All formats support the same configuration options. Choose the format that best
134135
"retry_after_failure": false,
135136
"allow_abort": false,
136137
"message_length_limit": 0,
138+
"preview": false,
137139
"allowed_prefixes": [
138140
"Merge",
139141
"Revert",
@@ -190,6 +192,7 @@ All formats support the same configuration options. Choose the format that best
190192
retry_after_failure: false
191193
allow_abort: false
192194
message_length_limit: 0
195+
preview: false
193196
allowed_prefixes:
194197
- Merge
195198
- Revert
@@ -237,6 +240,7 @@ Key configuration categories include:
237240
- **Changelog**: `changelog_file`, `changelog_format`, `changelog_incremental`, `update_changelog_on_bump`
238241
- **Bumping**: `bump_message`, `major_version_zero`, `prerelease_offset`, `pre_bump_hooks`, `post_bump_hooks`
239242
- **Commit Validation**: `allowed_prefixes`, `message_length_limit`, `allow_abort`, `retry_after_failure`
243+
- **Interactive Preview**: `preview`
240244
- **Customization**: `customize`, `style`, `use_shortcuts`, `template`, `extras`
241245

242246
## Customization

0 commit comments

Comments
 (0)