-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemacs.linux
More file actions
executable file
·33 lines (28 loc) · 1.07 KB
/
emacs.linux
File metadata and controls
executable file
·33 lines (28 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
set -ex
# This version works with the homebrew build of emacs
module load emacs
[ -n "${EMACS_ROOT}" ] && [ -d "${EMACS_ROOT}" ]
emacs_server="${EMACS_ROOT}/bin/emacs"
emacs_client="${EMACS_ROOT}/bin/emacsclient"
if [[ $# -gt 1 ]]; then
if [ "$1" == "-batch" ] || [ "$1" == "--batch" ]; then
echo "Emacs compiler mode with: $@"
exec ${emacs_server} "$@"
fi
fi
emacs_server_pattern="Emacs.app/Contents/MacOS/Emacs"
server_pid=$(ps aux | grep -v grep | grep -Ei "${emacs_server_pattern}" | awk '{print $2}')
# Check if there is already an emacs process (has to be written like this)
if [ ! -z "${server_pid}" ]; then
#if [ `pgrep -f 'Emacs.*--daemon'` ]; then
which osascript > /dev/null 2>&1 && \
osascript -e 'tell application "Emacs" to activate'
# Get the number of all frames
num_frames=$(${emacs_client} -e '(length (frame-list))')
if [[ $num_frames -lt 2 ]]; then args=-nc; else args=-n; fi
${emacs_client} ${args} --quiet --no-wait "$@"
else
echo "Initializing emacs server"
${emacs_server} --no-splash "$@" &
fi