Skip to content

Instantly share code, notes, and snippets.

@JeanRibes
Last active April 15, 2024 10:22
Show Gist options
  • Save JeanRibes/b6198102ac18dde823deed97e8cf263b to your computer and use it in GitHub Desktop.
Save JeanRibes/b6198102ac18dde823deed97e8cf263b to your computer and use it in GitHub Desktop.
gitmoji Bash/ZSH plugin

gitmoji chooser

This command will let you choose a "gitmoji" and pre-fill a git commit -m command for you, all without leaving the terminal

requirements

requires fzf to be installed and available in the $PATH

Bash

paste the contents of gitmoji.bash in ~/.bashrc``, or source` the file

do not execute it as a script, it will not work

ZSH

installation

place file in ~/.oh-my-zsh/custom/plugins/gitmoji/gitmoji.plugin.zsh

usage

use command gitmoji to choose an emoji, and the plugin will pre-fill a git commit -m command for you, which you can edit before executing

# generate with
# curl -L https://github.com/carloscuesta/gitmoji/raw/master/packages/gitmojis/src/gitmojis.json|jq -r '.gitmojis[] | "\(.emoji):\(.description)"'
gitmojis=$(cat << EOF | tr '\n' '@'
🎨:Improve structure / format of the code.
⚑️:Improve performance.
πŸ”₯:Remove code or files.
πŸ›:Fix a bug.
πŸš‘οΈ:Critical hotfix.
✨:Introduce new features.
πŸ“:Add or update documentation.
πŸš€:Deploy stuff.
πŸ’„:Add or update the UI and style files.
πŸŽ‰:Begin a project.
βœ…:Add, update, or pass tests.
πŸ”’οΈ:Fix security or privacy issues.
πŸ”:Add or update secrets.
πŸ”–:Release / Version tags.
🚨:Fix compiler / linter warnings.
🚧:Work in progress.
πŸ’š:Fix CI Build.
⬇️:Downgrade dependencies.
⬆️:Upgrade dependencies.
πŸ“Œ:Pin dependencies to specific versions.
πŸ‘·:Add or update CI build system.
πŸ“ˆ:Add or update analytics or track code.
♻️:Refactor code.
βž•:Add a dependency.
βž–:Remove a dependency.
πŸ”§:Add or update configuration files.
πŸ”¨:Add or update development scripts.
🌐:Internationalization and localization.
✏️:Fix typos.
πŸ’©:Write bad code that needs to be improved.
βͺ️:Revert changes.
πŸ”€:Merge branches.
πŸ“¦οΈ:Add or update compiled files or packages.
πŸ‘½οΈ:Update code due to external API changes.
🚚:Move or rename resources (e.g.: files, paths, routes).
πŸ“„:Add or update license.
πŸ’₯:Introduce breaking changes.
🍱:Add or update assets.
♿️:Improve accessibility.
πŸ’‘:Add or update comments in source code.
🍻:Write code drunkenly.
πŸ’¬:Add or update text and literals.
πŸ—ƒοΈ:Perform database related changes.
πŸ”Š:Add or update logs.
πŸ”‡:Remove logs.
πŸ‘₯:Add or update contributor(s).
🚸:Improve user experience / usability.
πŸ—οΈ:Make architectural changes.
πŸ“±:Work on responsive design.
🀑:Mock things.
πŸ₯š:Add or update an easter egg.
πŸ™ˆ:Add or update a .gitignore file.
πŸ“Έ:Add or update snapshots.
βš—οΈ:Perform experiments.
πŸ”οΈ:Improve SEO.
🏷️:Add or update types.
🌱:Add or update seed files.
🚩:Add, update, or remove feature flags.
πŸ₯…:Catch errors.
πŸ’«:Add or update animations and transitions.
πŸ—‘οΈ:Deprecate code that needs to be cleaned up.
πŸ›‚:Work on code related to authorization, roles and permissions.
🩹:Simple fix for a non-critical issue.
🧐:Data exploration/inspection.
⚰️:Remove dead code.
πŸ§ͺ:Add a failing test.
πŸ‘”:Add or update business logic.
🩺:Add or update healthcheck.
🧱:Infrastructure related changes.
πŸ§‘πŸ’»:Improve developer experience.
πŸ’Έ:Add sponsorships or money related infrastructure.
🧡:Add or update code related to multithreading or concurrency.
🦺:Add or update code related to validation.
EOF
)
gitmoji() {
emoji=$(echo $gitmojis | tr '@' '\n'| fzf | cut -d: -f1)
if [[ -n "$emoji" ]]; then
echo "chose $emoji"
bind '"\e[0n": "git commit -m '"'$emoji"'"'; printf '\e[5n'
fi
}
# generate with
# curl -L https://github.com/carloscuesta/gitmoji/raw/master/packages/gitmojis/src/gitmojis.json|jq -r '.gitmojis[] | "\(.emoji):\(.description)"'
gitmojis=$(cat << EOF
🎨:Improve structure / format of the code.
⚑️:Improve performance.
πŸ”₯:Remove code or files.
πŸ›:Fix a bug.
πŸš‘οΈ:Critical hotfix.
✨:Introduce new features.
πŸ“:Add or update documentation.
πŸš€:Deploy stuff.
πŸ’„:Add or update the UI and style files.
πŸŽ‰:Begin a project.
βœ…:Add, update, or pass tests.
πŸ”’οΈ:Fix security or privacy issues.
πŸ”:Add or update secrets.
πŸ”–:Release / Version tags.
🚨:Fix compiler / linter warnings.
🚧:Work in progress.
πŸ’š:Fix CI Build.
⬇️:Downgrade dependencies.
⬆️:Upgrade dependencies.
πŸ“Œ:Pin dependencies to specific versions.
πŸ‘·:Add or update CI build system.
πŸ“ˆ:Add or update analytics or track code.
♻️:Refactor code.
βž•:Add a dependency.
βž–:Remove a dependency.
πŸ”§:Add or update configuration files.
πŸ”¨:Add or update development scripts.
🌐:Internationalization and localization.
✏️:Fix typos.
πŸ’©:Write bad code that needs to be improved.
βͺ️:Revert changes.
πŸ”€:Merge branches.
πŸ“¦οΈ:Add or update compiled files or packages.
πŸ‘½οΈ:Update code due to external API changes.
🚚:Move or rename resources (e.g.: files, paths, routes).
πŸ“„:Add or update license.
πŸ’₯:Introduce breaking changes.
🍱:Add or update assets.
♿️:Improve accessibility.
πŸ’‘:Add or update comments in source code.
🍻:Write code drunkenly.
πŸ’¬:Add or update text and literals.
πŸ—ƒοΈ:Perform database related changes.
πŸ”Š:Add or update logs.
πŸ”‡:Remove logs.
πŸ‘₯:Add or update contributor(s).
🚸:Improve user experience / usability.
πŸ—οΈ:Make architectural changes.
πŸ“±:Work on responsive design.
🀑:Mock things.
πŸ₯š:Add or update an easter egg.
πŸ™ˆ:Add or update a .gitignore file.
πŸ“Έ:Add or update snapshots.
βš—οΈ:Perform experiments.
πŸ”οΈ:Improve SEO.
🏷️:Add or update types.
🌱:Add or update seed files.
🚩:Add, update, or remove feature flags.
πŸ₯…:Catch errors.
πŸ’«:Add or update animations and transitions.
πŸ—‘οΈ:Deprecate code that needs to be cleaned up.
πŸ›‚:Work on code related to authorization, roles and permissions.
🩹:Simple fix for a non-critical issue.
🧐:Data exploration/inspection.
⚰️:Remove dead code.
πŸ§ͺ:Add a failing test.
πŸ‘”:Add or update business logic.
🩺:Add or update healthcheck.
🧱:Infrastructure related changes.
πŸ§‘πŸ’»:Improve developer experience.
πŸ’Έ:Add sponsorships or money related infrastructure.
🧡:Add or update code related to multithreading or concurrency.
🦺:Add or update code related to validation.
EOF
)
function gitmoji() {
emoji=$(echo $gitmojis | fzf | cut -d: -f1)
if [[ -n "$emoji" ]]; then
print -z "git commit -m '$emoji"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment