Skip to content

Instantly share code, notes, and snippets.

@sarangnx
Last active October 7, 2020 08:34
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 sarangnx/1aa3d5637347d8da42e94f57fbf6196b to your computer and use it in GitHub Desktop.
Save sarangnx/1aa3d5637347d8da42e94f57fbf6196b to your computer and use it in GitHub Desktop.
bashrc settings
git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[ \1 ] /'
}
PS1="\[\033[02;37m\]\$(git_branch)\[\033[00m\]\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\W \[\033[00m\]\$ "
# Git commit using emoji
cm() {
# Menu
echo "[ 0 ] 🌟 feat"
echo "[ 1 ] πŸ”¨ fix"
echo "[ 2 ] πŸ“” docs"
echo "[ 3 ] 🌈 style"
echo "[ 4 ] ✨ refactor"
echo "[ 5 ] πŸ” test"
echo "[ 6 ] πŸ’» chore"
echo "[ 7 ] πŸ“¦ deps"
# take user input
# -n 1 takes 1 character input
# -s does not echo user input
read -n 1 -s option
# array of prefixes
prefixes=( "🌟 feat" "πŸ”¨ fix" "πŸ“” docs" "🌈 style" "✨ refactor" "πŸ” test" "πŸ’» chore" "πŸ“¦ deps" )
if ! [[ $option =~ ^[0-7]$ ]]; then
echo "Invalid Selection πŸ’"
return
fi
git commit -m "${prefixes[$option]}: $@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment