Skip to content

Commit 01a2780

Browse files
committed
docs(customize): add shortcut keys section with cz_customize example and key rules
1 parent ee49266 commit 01a2780

File tree

1 file changed

+44
-4
lines changed

1 file changed

+44
-4
lines changed

docs/customization/config_file.md

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,47 @@ Example:
188188

189189
### Shortcut keys
190190

191-
When the `use_shortcuts` config option is enabled, Commitizen can show and use keyboard shortcuts to select items from lists directly.
192-
For example, when using the `cz_conventional_commits` Commitizen template, shortcut keys are shown when selecting the commit type.
193-
Unless otherwise defined, keyboard shortcuts will be numbered automatically.
194-
To specify keyboard shortcuts for your custom choices, provide the shortcut using the `key` parameter in dictionary form for each choice you would like to customize.
191+
For a basic overview of `use_shortcuts` and how the default menu looks, see the [`use_shortcuts` option](../config/option.md#use_shortcuts).
192+
193+
#### `use_shortcuts` with `cz_customize`
194+
195+
When using `cz_customize`, enabling `use_shortcuts` lets you set an optional `key` for each list/select choice so that choice shows your chosen shortcut. Rules below.
196+
197+
Example:
198+
199+
```toml title="pyproject.toml"
200+
[tool.commitizen]
201+
name = "cz_customize"
202+
use_shortcuts = true
203+
204+
[tool.commitizen.customize]
205+
message_template = "{{prefix}}: {{message}}"
206+
schema = "<type>: <body>"
207+
schema_pattern = "(feat|fix|docs|test):(\\s.*)"
208+
209+
[[tool.commitizen.customize.questions]]
210+
type = "list"
211+
name = "prefix"
212+
message = "Select the type of change you are committing"
213+
choices = [
214+
{ value = "feat", name = "feat: A new feature.", key = "f" },
215+
{ value = "fix", name = "fix: A bug fix.", key = "x" },
216+
{ value = "docs", name = "docs: Documentation only changes", key = "d" },
217+
{ value = "test", name = "test: Adding or correcting tests", key = "t" }
218+
]
219+
220+
[[tool.commitizen.customize.questions]]
221+
type = "input"
222+
name = "message"
223+
message = "Commit body: "
224+
```
225+
226+
![Menu with custom shortcut keys settings](../images/cli_interactive/shortcut_custom.gif)
227+
228+
**Rules for `key`**
229+
230+
| Rule | Description |
231+
|------|-------------|
232+
| Allowed | Lowercase `a``z` or digits `0``9` only |
233+
| Uniqueness | Each `key` must be unique among all choices |
234+
| Optional | Omit `key` to use default numeric order (1, 2, 3, …) |

0 commit comments

Comments
 (0)