Almost all of my tube time is spent in 4 programs: Emacs; Safari; Reeder; and Mail, roughly in that order. Naturally, I try to stay in Emacs as much as I can. In particular, I’ve long bound 【Ctrl+c s】 to start a bash shell in an Emacs buffer.
Recently, I came across this post and video by Eric Himmelreich on ways he makes Emacs fit his workflow. He demonstrates two things. First, he has a function that splits his Emacs frame into two side-by-side windows of 80 characters each and makes the frame take up all available screen height. I do much the same thing except that the window configuration is performed by a system-specific initialization file.
The second thing is more interesting. He likes to have a full screen terminal running that he can bring up when he needs it. He decided to integrate that into Emacs by writing a keyboard macro to start a full screen
eshell and another to restore the previous window configuration. That seemed pretty useful to me and after playing around with
eshell a bit, I decided I liked it better than running bash so I decided to implement something similar to what Himmelreich did.
Rather than use keyboard macros, as he did, I stole the idea behind Magnar Sveen’s excellent magit-status hack. The idea is simple: typing 【Hyper+e】 saves the current window configuration, starts
eshell, and deletes the other windows. A subsequent 【Hyper+e】 restores the window configuration. The code is simple
(global-set-key (kbd "H-e") (lambda () "Bring up a full-screen eshell or restore previous config." (interactive) (if (string= "eshell-mode" major-mode) (jump-to-register :eshell-fullscreen) (progn (window-configuration-to-register :eshell-fullscreen) (eshell) (delete-other-windows)))))