Skip to content

Instantly share code, notes, and snippets.

@csturtevant
Created May 4, 2017 20:15
Show Gist options
  • Save csturtevant/56139fe5f2833de521aea46732544d42 to your computer and use it in GitHub Desktop.
Save csturtevant/56139fe5f2833de521aea46732544d42 to your computer and use it in GitHub Desktop.
vi pipe to emacs
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