Quick Tip: Launching Emacs from the Terminal Like a Pro

Cover Image for Quick Tip: Launching Emacs from the Terminal Like a Pro
Rahul M. Juliato
Rahul M. Juliato

Speed up your Emacs experience and enjoy quicker startup times with these clever tricks and optimizations.

Launching Emacs

As you can see in the image above, I have configured my Emacs to be fully featured, capable of handling a wide range of tasks.

I use it as an integrated development environment (IDE), a music player, a note-taking app, a frontend for several daemon services, and more.

However, this versatility comes at a cost—Emacs takes a significant amount of time to start up due to my preference for installing packages manually rather than using use-package (the reasons for this choice could fill another post).

In this context, the "right way" to use Emacs is to take advantage of its server/client architecture. Essentially, you can run Emacs as a server and open multiple command-line (CLI) or graphical user interface (GUI) clients, all of which share the same server instance.

To achieve this, I like to set up a few aliases in my .bashrc file:

alias emd='emacs --daemon'
alias em='emacsclient -t'
alias emg='emacsclient -c'

Using these aliases, running emd starts the Emacs server. You only need to do this once when you start your terminal or set it to run as a server/daemon on system startup.

The initial startup time is the only downside, but this delay occurs only once. Afterward, using em opens the full-featured Emacs instantly. You can even use it to open a specific file like this: em my_file.txt.

Similarly, we have emg, which does the same as em but opens a client in graphical mode.

Any instance opened with em or emg will share the same Emacs server, allowing you to take advantage of data sharing between different "sessions."

In conclusion, by harnessing the power of Emacs' server/client architecture and a few nifty aliases, you can transform your Emacs experience into a seamlessly versatile tool for your daily tasks. So, why wait? Dive into the world of efficient, lightning-fast Emacs sessions, and let your creativity and productivity soar. Happy hacking!