Skip to content

Instantly share code, notes, and snippets.

/.sh Secret

Created January 27, 2018 01:12
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 anonymous/8f4c1c3314fa85133eb9c8b672a9bb87 to your computer and use it in GitHub Desktop.
Save anonymous/8f4c1c3314fa85133eb9c8b672a9bb87 to your computer and use it in GitHub Desktop.
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