I would like to have a workflow where I could make my F9 key open up a shell in a split pane, and then have the same key effectively do a C-x 0
on it. That way I could split, run a command, do some stuff, and go back to the file I was editing.
My attempt at this has some problems:
(defun split-shell-toggle ()
(interactive)
(split-window-below)
(eshell))
(global-set-key (kbd "<f9>") 'split-shell-toggle)
In particular, I need to modify the function to check if the pane is visible, and then close the pane if it is. Right now I get this kind of thing:
It keeps splitting again and again. How can I check if the pane is already open, and close it if it is?
my-custom-eshell-function
by modifying the functioneshell
-- it is only a few lines long, and the key ingredient you will be modifying is(pop-to-buffer-same-window buf)
. And, here is your keyboard shourtcut:(global-set-key [f9] 'my-custom-eshell-function)
. To find the source code of the function, you can useM-x find-function RET eshell RET
Instead ofpop-to-buffer-same-window
, you can use something better from thewindow.el
library or create your owndisplay-buffer
function. – lawlist May 11 '15 at 22:06*eshell*
buffer? A*scratch*
buffer perhaps? – lawlist May 12 '15 at 2:48