You are not logged in.
This little wrapper script simplifies using emacs(client) from the commandline in X.
#!/bin/sh
# Frontend to emacs/emacsclient
#
# Use a single emacs per user in server mode for all subsequent calls
# to 'emacs' in a NetWM comliant window manager, bringing emacs up
# front on the current desktop.
#
# requires either xdtotool (http://www.semicomplete.com/projects/xdotool/)
# or wmctrl (http://www.sweb.cz/tripie/utils/wmctrl/)
#
# Install: 1. Move your emacs binary to 'emacs-bin' and install this
# script as 'emacs'
# 2. Add '(server-start)' to your ~/.emacs
function show_emacs {
# if in X11 move emacs window to the current desktop, raise the
# window, and give it focus.
if [ "$XAUTHORITY" ]; then
if [ `which xdotool` ]; then
WID=`xdotool search --class Emacs | head -n1`
xdotool set_desktop_for_window $WID `xdotool get_desktop`
xdotool windowraise $WID
xdotool windowfocus $WID
elif [ `which wmctrl` ]; then
wmctrl -R emacs
fi
fi
}
# check wether an emacs server is around
if [ ! `fuser /tmp/emacs$UID/server 2> /dev/null` ]; then
# no server around, start with args
if [ "$XAUTHORITY" ]; then
emacs-bin $@ > /dev/null 2>&1 &
else
emacs-bin $@
fi
else
if [ "$@" ]; then
# pass args to emacsclient
emacsclient -n "$@" > /dev/null 2>&1
show_emacs
else
# no args, just bring emacs up front
show_emacs
fi
fi
Offline