-
-
Save silvercircle/feaead2ce149d133b63bb2c9e35e2bd1 to your computer and use it in GitHub Desktop.
Start emacsclient and only create a new frame if none exists. Otherwise reuse frame. Pass -nw to force console-emacs
This file contains hidden or 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
#!/bin/bash -e | |
if [[ "$DISPLAY" ]]; then | |
frame=`emacsclient -a '' -e "(member \"$DISPLAY\" (mapcar 'terminal-name (frames-on-display-list)))" 2>/dev/null` | |
[[ "$frame" == "nil" ]] && opts='-c' # if there is no frame open create one | |
[[ "${@/#-nw/}" == "$@" ]] && opts="$opts -n" # don't wait unless we've asked to run in a terminal | |
else | |
opts='-nw' | |
fi | |
exec emacsclient -a '' $opts "$@" | |
Source and copyright: https://emacs.stackexchange.com/questions/12894/make-emacsclient-create-a-frame-only-if-there-isnt-one-already |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment