diff --git a/git/.gitconfig.symlink b/git/.gitconfig.symlink index de783c6..352a3d0 100644 --- a/git/.gitconfig.symlink +++ b/git/.gitconfig.symlink @@ -3,6 +3,7 @@ [core] attributesFile = ~/dotfiles/git/.gitattributes excludesFile = ~/dotfiles/git/.gitignore + hooksPath = ~/dotfiles/git/hooks [user] # Do not guess the user's identity. diff --git a/git/commit_template b/git/commit_template index 0a70d01..4ed7f15 100644 --- a/git/commit_template +++ b/git/commit_template @@ -1,6 +1,6 @@ -# Title: Summary, imperative, start upper case, don't end with a period -# No more than 50 chars. #### 50 chars is here: # +# No more than 50 chars. #### 50 chars is here: # +# Title: Summary, imperative, start upper case, don't end with a period # Remember blank line between title and body. # Body: Explain *what* and *why* (not *how*). diff --git a/git/hooks/prepare-commit-msg b/git/hooks/prepare-commit-msg new file mode 100755 index 0000000..ce0b927 --- /dev/null +++ b/git/hooks/prepare-commit-msg @@ -0,0 +1,33 @@ +#!/bin/bash +############################################################################### +## Title: gitmoji-fuzzy-hook-init +## Brief: It opens a fuzzy searcher with gitmojis, to allow the git commit +## caller to select one. For git commit visual mode +## it adds a description of the selected emoji. +## Args: +## $1: File of the commit message +## $2: Commit type +## $3: Commit Hash +## +## Returns: +## Prepends a selectable gitmoji to the git commit message. +## +## Source: https://gitlab.com/raabf/gitmoji-fuzzy-hook +## Author: Fabian Raab +## Dependencies: gitmoji-fuzzy-hook +############################################################################### + +[ -t 1 ] # checks if this script is called from a terminal +emoji="$(/Users/marley/.local/share/gitmoji-fuzzy-hook/bin/gitmoji-fuzzy-hook-exec.sh $? $@)" + +msg_file="$1" +msg="$(cat "$msg_file")" + +# Do here whatever you want with the commit message before prepending the emoji +# to it and writing the message to the commit file. + +if [ ! -z "${emoji}" ]; then # surpress the space if there is no emoji + msg="${emoji} ${msg}" +fi +echo -e "$msg" > "$msg_file" + diff --git a/git/install.fish b/git/install.fish index 0dc148d..8c35125 100755 --- a/git/install.fish +++ b/git/install.fish @@ -8,4 +8,7 @@ source "$DOT/homebrew/brew_utils.fish" print_subtitle Git brew_install "Github CLI" gh -brew_install Gitmoji gitmoji +execute \ + "git clone https://gitlab.com/raabf/gitmoji-fuzzy-hook.git ~/.local/share/gitmoji-fuzzy-hook && \ + ln -f -s ~/.local/share/gitmoji-fuzzy-hook/bin/gitmoji-fuzzy-hook-init.sh $HOME/bin/gitmoji-fuzzy-hook-init" \ + gitmoji-fuzzy-hook