Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mori-dev/322d3e063c86aab6d135548ec9dbdb37 to your computer and use it in GitHub Desktop.
Save mori-dev/322d3e063c86aab6d135548ec9dbdb37 to your computer and use it in GitHub Desktop.
#!/bin/bash
[ -z `which emacsclient 2>&1` ] && { echo 'emacsclient not found' >&2; exit 1; }
[ -z `which git 2>&1` ] && { echo 'git not found' >&2; exit 1; }
[ -z `which peco 2>&1` ] && { echo 'peco not found' >&2; exit 1; }
function open_emacsclient {
if [ $# -eq 0 ]; then
TMP_FILE=`mktemp /tmp/emacsclient.XXXXXX`
cat > $TMP_FILE
sexp=$(cat <<EOF
(let ((b (create-file-buffer "*stdin*")))
(switch-to-buffer b)
(insert-file-contents "${TMP_FILE}")
(delete-file "${TMP_FILE}")
(diff-mode))
EOF
)
emacsclient -a emacs -e "$sexp"
fi
}
# copy from https://gist.github.com/fukajun/edea3c4f36e37bf36e8b
hash=`git log --graph --pretty=format:'%d %an: %s %ar %h' | peco | awk -F ' ' '{ print $NF }'`
git show $hash | open_emacsclient
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment