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 ()

(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:

enter image description here

It keeps splitting again and again. How can I check if the pane is already open, and close it if it is?

  • I would recommend creating a new function called my-custom-eshell-function by modifying the function eshell -- 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 use M-x find-function RET eshell RET Instead of pop-to-buffer-same-window, you can use something better from the window.el library or create your own display-buffer function.
    – lawlist
    May 11 '15 at 22:06
  • What do you want below the *eshell* buffer? A *scratch* buffer perhaps?
    – lawlist
    May 12 '15 at 2:48
  • 1
    You may interest in shell-pop.
    – Tu Do
    May 12 '15 at 2:52
  • @TuDo that is exactly what I'm looking for, want to make that an answer?
    – tlehman
    May 12 '15 at 17:48

You may interest in shell-pop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.