Last active
March 17, 2017 03:50
-
-
Save mori-dev/322d3e063c86aab6d135548ec9dbdb37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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