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
}