-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathgitCommit.sh
More file actions
32 lines (25 loc) · 983 Bytes
/
gitCommit.sh
File metadata and controls
32 lines (25 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
# Check if there are any changes to commit
if [[ -z $(git status -s) ]]; then
echo "No changes to commit."
exit 0
fi
# Prompt for Gitmoji
echo "Select a Gitmoji:"
gitmoji_list=("✨ New feature" "🐛 Bug fix" "🔧 Maintenance" "📚 Documentation" "✅ Tests" "♻️ Refactor" "🎨 Style" "🔥 Remove" "🚀 Performance" "🏗️ Initial Construction" "🚧 WIP")
for i in "${!gitmoji_list[@]}"; do
echo "$i. ${gitmoji_list[$i]}"
done
read -p "Enter the number corresponding to the Gitmoji: " gitmoji_number
if [[ ! "$gitmoji_number" =~ ^[0-9]+$ ]] || [ "$gitmoji_number" -lt 0 ] || [ "$gitmoji_number" -ge "${#gitmoji_list[@]}" ]; then
echo "Invalid selection."
exit 1
fi
selected_gitmoji="${gitmoji_list[$gitmoji_number]}"
# Prompt for commit message
read -p "Enter commit message: " commit_message
# Commit changes
git add .
git commit -m "$selected_gitmoji $commit_message"
git push origin main
echo "Changes committed and pushed successfully."