Open Mobile Menu Close Mobile Menu

Run an Emacs function from the terminal

Since I like to update my system packages on a daily basis, I was looking into ways of accomplishing the same for Spacemacs, without manually opening it, running the update function, then closing it.

Doing this along with regularly updating to the latest commit on the Spacemacs develop branch allows me to stay on the bleeding edge of the development, and I experienced breaking changes surprisingly rarely.

The command I used to accomplish the above is:

emacs --no-window-system --kill --eval '(configuration-layer/update-packages t)'

--no-window-system runs the terminal version of Emacs (as opposed to the X/GUI version)
--kill exits Emacs after the command has been run, without confirmation
--eval '(command)' evalutes the given command

Emacs could also be ran in the terminal without opening an instances at all, in the batch mode. A fun way to try this is to play the cyberpunk game Dunnet, which has been a part of Emacs for decades:

emacs --batch -l dunnet

Have fun!

If you enjoyed this article, subscribe to Miloš's Monthly Musings to get more articles like it in the future: