Bash completion and git commit --message

I am using git on the command line. I often develop new features in Git branches named after the Jira problems ( Wikipedia: JIRA ) related to them, for example. branch "new-123" for the ticket "Gin" "NEW-123".

I have a local Git hook-commit-msg hook that will create a commit message by selecting an item from a Jira ticket from Jira. For instance. "Finished # NEW-123: Cool new feature."

However, I prefer to commit directly from the command line:

git commit -m "Finished #NEW-123: Cool new feature" .

I would like to create the quoted commit message just by pressing [TAB].

I know the bash completion mechanism ( Bash: an introduction to programmable completion ). But how to use it together with existing command completion (git has excellent completion in bash)? Can I "bind" the completion?

Or do I need to reprogram the Git completion functions (perhaps by adding a binding to my custom function)?

+6
source share
1 answer

You can have a wrapper script, and then write for it <bash autocomplete. Then on the command line you will use, for example. git-commit or commit as your command instead of git commit , and you will have full control over autocomplete. (I already have commit as an alias for git commit , because I do so much.)

I agree with all the comments above, although if you did this on your team, I would be disappointed; you should spend time on your commit logs and post some details there without trying to push them in one line. But it is up to you.

0
source

Source: https://habr.com/ru/post/985408/


All Articles