Skip to content

Instantly share code, notes, and snippets.

Last active May 23, 2017 10:01
What would you like to do?
fish function that prepares a git commit command with message containing the jira ticket number
# save as ~/.config/fish/functions/
# Use:
# Assuming you are in a git repository of a bitbucket / jira branch using the atlassian jira git flow conventions
# example "feature/EXP-1337-cool-new-feature
# MAC USERS CHANGE "sed -r" to "sed -E"
# > commit
# will expand to
# > git commit -m 'EXP-1337: '
# resting the cursor just before the last quote
set _ticket (git rev-parse --abbrev-ref HEAD 2>/dev/null | \
sed -r 's#^(feature|hotfix|bugfix|experiment)/?([[:alpha:]]+-[[:digit:]]+).*$#\2#')
commandline -r "git commit -m '$_ticket: '"
commandline -C (expr (commandline -C) - 1)
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment