Skip to content

Instantly share code, notes, and snippets.

@BruceGitHub
Created July 3, 2018 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BruceGitHub/cbc63c3e86c33613a0b80635cab04238 to your computer and use it in GitHub Desktop.
Save BruceGitHub/cbc63c3e86c33613a0b80635cab04238 to your computer and use it in GitHub Desktop.
from name branch as XXXX-YYYYY extract string and will prompt "xxx-yy: ..." for commit message
#!/usr/bin/env bash
BRANCHNAME=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/')
FLAT_COMMIT=$( echo $BRANCHNAME | tr -d '(' | tr -d ')' )
IFS='-' read -r -a myarray <<< "$FLAT_COMMIT"
echo "Digita il messaggio di commit: puoi modificare anche il nome del branch "
INPUT_COMMIT=$(echo "${myarray[0]}"-"${myarray[1]}")
read -i "$INPUT_COMMIT: " -e answer
git commit -am "$answer"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment