Skip to content

Instantly share code, notes, and snippets.

@vogelino
Last active February 2, 2021 11:26
Show Gist options
  • Save vogelino/06b71c1c91734906136e8ecbb4ec9e9b to your computer and use it in GitHub Desktop.
Save vogelino/06b71c1c91734906136e8ecbb4ec9e9b to your computer and use it in GitHub Desktop.
A function that executes commitizen's git-cz command or installs it if not present (using npm)
# Commit using commitizen
commit-with-commitizen() {
if [[ $(command-exists "git-cz") -eq 0 ]]; then
npm install --global commitizen
fi
git-cz
}
@vogelino
Copy link
Author

vogelino commented Feb 2, 2021

This ZSH function that checks if commitizen is installed globally, install it if not and then uses commitizen to commit.

Optional: Add an alias to always commit using commitizen

Add this alias to your .zshrc

# Commit with commitizen
unalias gc # If you are using the zsh git plugin, you need to unalias the gc alias first
alias gc="commit-with-commitizen"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment