Created
August 7, 2011 11:28
-
-
Save vedang/1130303 to your computer and use it in GitHub Desktop.
Shell script to start a new instance of emacs or switch to an already running one.
This file contains 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 | |
# get id of emacs | |
win=$(xdotool search --onlyvisible --class emacs | head -1) | |
if [ "x$win" = x ]; then | |
# Emacs is not running | |
# switch to viewport 1, which is my coding viewport | |
~/incoming-src/dotfiles/scripts/compiz-send.py vpswitch switch_to_1_key | |
gxmessage -center -timeout 2 -nofocus -buttons "" -borderless "loading emacs..."& | |
# start Emacs | |
exec /usr/local/bin/emacs & | |
else | |
# Emacs is already running... | |
if [ $win = $(xdotool getwindowfocus) ]; then | |
# ...and focused | |
# do nothing | |
sleep 0.2; | |
else | |
# switch to it | |
xdotool windowactivate $win | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment