I really enjoyed the “Making the Most of Terminal Emacs” stream.
My main problem with terminal emacs was always not being able to use the super key as my “leader key” for personal keybindings.
But there is a way! (besides waiting for ghostty, which might support everything out of the box)
The basic setup is really easy.
Use a terminal emulator that supports the Kitty Keyboard Protocol (e.g. kitty, foot, wezterm, alacritty)
Install the kkp package in emacs.
(use-package kkp
:config
(global-kkp-mode 1))
I haven’t dug into all the customization of kkp in emacs yet. But at the very least, it already lets me use the super key. It probably enables a lot of other special modifiers/combinations that normally don’t work in terminal emacs.
Shortlist of the other most useful things for me in terminal emacs:
;; enable terminal emacs yank/paste to use system clipboard
(use-package xclip
:config
(xclip-mode 1))
;; if using vertico+consult, use the minibuffer for completion in region
;; (terminal emacs doesn't support child frames)
(setq completion-in-region-function
(lambda (&rest args)
(apply (if vertico-mode
#'consult-completion-in-region
#'completion--in-region)
args)))
I’m experiencing an issue where the Meta key doesn’t function with Emacs in certain terminals.
I tried the ‘kkp’ package, it do enabled the Meta key in the following terminals:
iTerm on macOS
ssh to Termux on my Android phone using iTerm on macOS
I have only configured the Alt key to function as the Meta key in the terminal settings.
Ensuring Emacs operates efficiently in the terminal is of importance to me. At work, I’ve encountered several situations where I have to run Emacs in the terminal.
Most terminal emulators (at least of the ones that support kkp) have a whole bunch of default keybindings that do obscure things, that will prevent the keypress from ever being sent to the terminal application (emacs).
Ctrl+Shift+letter combinations are especially common for terminal emulators to use for default keybindings.
Of course, you will need to disable/remap all of the terminal emulator bindings that you want to be able to use for emacs bindings.
(some of these terminal emulator bindings only do something visible in certain situations, so it can easily look like nothing is happening at all, and that the terminal emulator doesn’t even recognize the binding…so it is safest to check the default bindings that are being used, you can’t always use the command (e.g. C-v) to view the raw keypress that the emulator is receiving. For some reason, if it is an internal command, it doesn’t seem to always report it for the C-v raw output.)
I don’t know how that would be possible…the TTY doesn’t support the KKP. You might have to write your own TTY by rewriting all of the low level keyboard input events to somehow recognize all of the modifier combinations as unique keyboard events.