Skip to content

Instantly share code, notes, and snippets.

@jiito
Last active December 5, 2023 20:24
Show Gist options
  • Save jiito/fa7d88820df4dea2b2ee12570f61b14a to your computer and use it in GitHub Desktop.
Save jiito/fa7d88820df4dea2b2ee12570f61b14a to your computer and use it in GitHub Desktop.
Git Commit Linear Id Prefix (zsh)
# GET LINEAR ID
setopt local_options BASH_REMATCH
REGEX="[A-Za-z]+-[0-9]+"
BRANCH=$(git branch --show-current)
if [[ $BRANCH =~ $REGEX ]]; then
PREFIX=$BASH_REMATCH[1]
fi
# COMMIT CHANGES WITH PREFIX
MESSAGE="$1"
if [[ ! -z "$PREFIX" ]]; then
MESSAGE="[$PREFIX]: "$MESSAGE
fi
git commit -S -m "$MESSAGE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment