Emacs 后台自动启动: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<syntaxhighlight lang="bash" | <syntaxhighlight lang="bash"> | ||
mkdir -p ~/.config/systemd/user | mkdir -p ~/.config/systemd/user | ||
nano ~/.config/systemd/user/emacs.service | nano ~/.config/systemd/user/emacs.service | ||
</syntaxhighlight> | |||
<pre> | |||
[Unit] | [Unit] | ||
Description=Emacs text editor as a daemon | Description=Emacs text editor as a daemon | ||
Line 15: | Line 17: | ||
[Install] | [Install] | ||
WantedBy=default.target | WantedBy=default.target | ||
</pre> | |||
<syntaxhighlight lang="bash"> | |||
systemctl --user daemon-reload | systemctl --user daemon-reload | ||
systemctl --user enable emacs.service | systemctl --user enable emacs.service | ||
Line 22: | Line 26: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
感谢 | 感谢 ChatGPT,上边全是他教的。从此以后,就可以随时启动 emacsclient 了。 |
Latest revision as of 23:00, 8 November 2024
mkdir -p ~/.config/systemd/user
nano ~/.config/systemd/user/emacs.service
[Unit] Description=Emacs text editor as a daemon Documentation=info:emacs man:emacs(1) [Service] Type=forking ExecStart=/usr/bin/emacs --daemon ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)" Restart=on-failure [Install] WantedBy=default.target
systemctl --user daemon-reload
systemctl --user enable emacs.service
systemctl --user start emacs.service
systemctl --user status emacs.service
感谢 ChatGPT,上边全是他教的。从此以后,就可以随时启动 emacsclient 了。