Spacemacs在systemd下使用技巧,后台运行

systemd启动系统已经在多个Linux版本下运行,Ubuntu、arch等。把emacs(spacemacs)作为系统服务运行可以大幅提高启动速度,改善使用体验。

创设systemd启动服务:

首先我们要新建一个systemd启动文件,可以参考emacs wiki。 文件要放到 ** /etc/systemd/system/emacs@.service**

[Unit]
Description=Emacs: the extensible, self-documenting text editor

[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(progn (setq kill-emacs-hook 'nil) (kill-emacs))"
Restart=always
User=%i
WorkingDirectory=%h

[Install]
WantedBy=multi-user.target

启动服务

通过systemd我们可以启动、禁止等服务

~$ sudo systemctl enable emacs@lefteris.service
~$ sudo systemctl disable emacs@lefteris.service
~$ sudo systemctl start emacs@lefteris.service
~$ sudo systemctl stop emacs@lefteris.service

~$ systemctl status emacs@lefteris.service

不需要root权限,客户模式下启动

要把emacs.service文件复制到_ ~/.config/systemd/user/emacs.service_

systemctl --user enable emacs
systemctl --user start emacs
systemctl --user stop emacs
systemctl --user disable emacs

客户端启动,启动时窗口最大化

-修改emacs.d文件

(add-to-list 'default-frame-alist '(fullscreen . fullboth)) 

-使用启动参数(我倾向于)

 emacsclient -c -F "'(fullscreen . fullboth)"

  emacsclient -c -F "'(fullscreen . maximized)"

  alias ecx="emacsclient -c -F \"'(fullscreen . maximized)\""

  emacsclient -c -F "((width . 100) (height . 100) (left . 400))"

持久化 Emacs 服务器

在emacs-china中说,直接使用 :

emacs --daemon &

这样就可以满足要求,尝试了下,使用spacemacs "space q q “ 推出后,emacs仍然驻留。

我们可以持久化 Emacs 服务器,在 Emacs 关闭的时候,服务器不被杀掉。只要设置 ~/.spacemacs 中 dotspacemacs-persistent-server 为 t 即可。

参考:

1、 https://emacs-china.org/t/emacs/720 1、[Running emacs as a daemon with systemd]http://blog.refu.co/?p=1296 2、https://medium.com/@bobbypriambodo/blazingly-fast-spacemacs-with-persistent-server-92260f2118b7

转载于:https://my.oschina.net/greister/blog/842899

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值