Created
May 4, 2017 20:15
-
-
Save csturtevant/56139fe5f2833de521aea46732544d42 to your computer and use it in GitHub Desktop.
vi pipe to emacs
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
function vi { | |
running=$(ps aux | grep emacs | grep -v grep) | |
if [ -z "$running" ] | |
then | |
open -a "Emacs" | |
echo "not running" | |
/bin/sleep 8 | |
fi | |
if [[ ! -t 0 ]] | |
then | |
echo "pipe" | |
TMP="$(mktemp /tmp/stdin-XXX)" | |
cat >>$TMP | |
# emacsclient -a emacs $TMP | |
emacsclient -a emacs -nc $TMP | |
rm -f $TMP | |
elif [[ -z "$1" ]] | |
then | |
echo "no pipe no args" | |
emacsclient -nc "." | |
else | |
echo "no pipe with args" | |
emacsclient -nc "$@" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment