diff --git a/bin/gitmoji.jq b/bin/gitmoji.jq new file mode 100755 index 0000000..7c99b6c --- /dev/null +++ b/bin/gitmoji.jq @@ -0,0 +1,3 @@ +#!/usr/bin/env -S jq -jf +# https://github.com/carloscuesta/gitmoji-cli/issues/1246 +.[] | "s=\(.code)=\(.emoji)=g;" diff --git a/functions/main.zsh b/functions/main.zsh index 4c91911..cccce71 100644 --- a/functions/main.zsh +++ b/functions/main.zsh @@ -13,9 +13,6 @@ (($+commands[grc])) || grc() {eval ${@[2,-1]}} (($+commands[jq])) || jq() {echo ';'} -mkdir -p ~/.gitmoji -touch ~/.gitmoji/gitmojis.json - # dictionary $ZINIT cannot be passed PLUGINS_DIR=${ZINIT[PLUGINS_DIR]} diff --git a/sources/git-checkout.zsh b/sources/git-checkout.zsh index 0fb9768..3e66f9c 100644 --- a/sources/git-checkout.zsh +++ b/sources/git-checkout.zsh @@ -5,11 +5,11 @@ case $group in ;; 'recent commit object name') git log --color=always $word | - perl -pe' '$(jq -j '.[] | "s=\(.code)=\(.emoji)=g;"' ~/.gitmoji/gitmojis.json) | + perl -pe' '$([ -f ~/.gitmoji/gitmojis.json ] && ${src:h:h}/bin/gitmoji.jq ~/.gitmoji/gitmojis.json || :) | delta ;; *) git log --color=always $word | - perl -pe' '$(jq -j '.[] | "s=\(.code)=\(.emoji)=g;"' ~/.gitmoji/gitmojis.json) + perl -pe' '$([ -f ~/.gitmoji/gitmojis.json ] && ${src:h:h}/bin/gitmoji.jq ~/.gitmoji/gitmojis.json || :) ;; esac diff --git a/sources/git-log.zsh b/sources/git-log.zsh index f7d4f54..61ee6b6 100644 --- a/sources/git-log.zsh +++ b/sources/git-log.zsh @@ -1,3 +1,3 @@ # :fzf-tab:complete:git-log:argument-1 git log --color=always $word | - perl -pe' '$(jq -j '.[] | "s=\(.code)=\(.emoji)=g;"' ~/.gitmoji/gitmojis.json) + perl -pe' '$([ -f ~/.gitmoji/gitmojis.json ] && ${src:h:h}/bin/gitmoji.jq ~/.gitmoji/gitmojis.json || :) diff --git a/sources/git-reflog.zsh b/sources/git-reflog.zsh index d253665..2041200 100644 --- a/sources/git-reflog.zsh +++ b/sources/git-reflog.zsh @@ -2,10 +2,10 @@ case $group in command) git reflog --color=always | - perl -pe' '$(jq -j '.[] | "s=\(.code)=\(.emoji)=g;"' ~/.gitmoji/gitmojis.json) + perl -pe' '$([ -f ~/.gitmoji/gitmojis.json ] && ${src:h:h}/bin/gitmoji.jq ~/.gitmoji/gitmojis.json || :) ;; reference) git reflog --color=always $word | - perl -pe' '$(jq -j '.[] | "s=\(.code)=\(.emoji)=g;"' ~/.gitmoji/gitmojis.json) + perl -pe' '$([ -f ~/.gitmoji/gitmojis.json ] && ${src:h:h}/bin/gitmoji.jq ~/.gitmoji/gitmojis.json || :) ;; esac