Skip to content

Instantly share code, notes, and snippets.

@nebirhos
Created May 26, 2011 01:32
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 nebirhos/992376 to your computer and use it in GitHub Desktop.
Save nebirhos/992376 to your computer and use it in GitHub Desktop.
Emacsclient wrapper
#!/bin/bash
# e - Edit file in emacs client, launchin emacs daemon if necessary
# alternate falls on emacs --daemon
EMACS='emacsclient --alternate-editor=""'
# count opened window frames
XFRAMES=`emacsclient -e "(frame-list)" 2>/dev/null | grep -o '#<frame [^F][^>]*>' | wc -l`
if [ $XFRAMES = 0 ]; then
EMACS="$EMACS -c"
fi
eval "$EMACS -n $@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment