Replace Your Terminal with Emacs
by Peter Stuart on July 24, 2021
When I’m working in Emacs, I use vterm as a terminal emulator. Rather than use a separate terminal emulator when I’m not already in Emacs, I’d like to be able to easily open a new Emacs frame with a fresh terminal in it. To do that, I wrote a script which runs emacsclientThis requires that you are running Emacs as a daemon.
, opens a new frame, and launches vterm:
emacsclient -cn --eval "(progn (x-focus-frame nil) (vterm t))"-cncreates a new frame, but does not wait for it to close before finishing the script.(x-focus-frame nil)focuses the new frame. On macOS, the new frame will often appear in the background without this.(vterm t)creates a newvtermbuffer. Without thetargument, it would switch to an already-existingvtermbuffer, if there was one.
On Linux, with XMonad as my window manager, I bind this script to S-s-<return>. On macOS, I use Alfred to bind it to ⇧⌘⏎.Alfred runs the script from the path of the workflow that contains it, so I add cd ~ to the beginning of the script on macOS.