Skip to content

Instantly share code, notes, and snippets.

@m4dz
Last active December 14, 2015 04:39
Show Gist options
  • Save m4dz/5030223 to your computer and use it in GitHub Desktop.
Save m4dz/5030223 to your computer and use it in GitHub Desktop.
Git pre-commit message that auto-fill the message with the tracker issue reference. You can also use the commiter.sh script as git core.editor to edit your commit message : the carret will be placed at the EOL, waiting for the rest of the message :)
#!/bin/sh
ISSUE=$(git symbolic-ref HEAD 2> /dev/null | cut -b 14-)
COLS=$((${#ISSUE} + 10))
subl -n -w "$*:1:$COLS"
#!/bin/sh
ISSUE=$(git symbolic-ref HEAD 2> /dev/null | cut -b 14-)
MSG=$(awk -v msg="Refs #$ISSUE -" 'NR==1{print msg}{print $0}' $1)
echo "$MSG" > $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment