commitizen icon indicating copy to clipboard operation
commitizen copied to clipboard

cz commit should let you type / search for the type of change you are commiting.

Open snus-kin opened this issue 8 months ago • 2 comments

Description

As a user I would like to be able to e.g. type 'fi' and 'fix' be highlighted. or 're' and 'refactor' be highlighted to save pressing the down arrow to get to the type I wish to select.

Possible Solution

No response

Additional context

No response

Related issues

No response

snus-kin avatar Apr 01 '26 15:04 snus-kin

Hi, here’s one solution that may help.

You can enable use_shortcuts in your configuration, which lets you select options more quickly with shortcuts.

Also, a bit of context that may be useful: Commitizen’s interactive prompts are built on top of tmbo/questionary. Based on your description, this seems more related to Questionary’s autocomplete prompt type.

If you need to further customize the question types, you may want to use the Python class customization approach.

ttw225 avatar Apr 02 '26 08:04 ttw225

Thanks, this is a bit of a start but doesn't work 100% amazingly. Might be useful for some other people though.

from commitizen.cz.conventional_commits import ConventionalCommitsCz
from prompt_toolkit.shortcuts import CompleteStyle


class CzCustomCz(ConventionalCommitsCz):
    def questions(self):
        questions = super().questions()

        for q in questions:
            if q.get("name") == "prefix":
                q["type"] = "autocomplete"
                if "choices" in q:
                    q["choices"] = [
                        c["name"] if isinstance(c, dict) else c for c in q["choices"]
                    ]
                q["match_middle"] = True
                q["ignore_case"] = True
                q["complete_style"] = CompleteStyle.MULTI_COLUMN
                q["complete_while_typing"] = True
                break

        return questions


discover_this = CzCustomCz

I think what I really want is a fzf lookup in the types but maybe this is just a limitation of questionary.

snus-kin avatar Apr 02 '26 09:04 snus-kin