到目前为止,.bashrc 中的这个函数定义似乎是一个完美的解决方案:
function e #open emacs in background and disown it, or if already running use emacsclient
{
echo "emacs function backgrounds and disowns emacs, or calls client if server already running; see .bashrc";
local FLUFFY="$@";
local SERVERSOCKET=/tmp/emacs${UID}/server ;
echo "trying to open: " $FLUFFY
echo " checking: " $SERVERSOCKET "for emacs server " ;
# test for existence of emacs server socket
if [ -e $SERVERSOCKET ]; then
echo "using emacsclient"
emacsclient -n $FLUFFY;
else
echo "starting emacs: make tea..."
emacs --geometry 10x10 --fullscreen --no-splash $FLUFFY & disown ;
fi;
}
这源于这个咒语:
FLUFFY=~/b.txt ; if [ -e /tmp/emacs1000/server ]; then emacsclient -n $FLUFFY; else emacs --geometry 10x10 --fullscreen --no-splash $FLUFFY & fi;
它通过检查用户 1000 的 emacs 服务器套接字的存在来完成我想要的。