Skip to content

Instantly share code, notes, and snippets.

@germ13
Last active August 29, 2015 14:10
Show Gist options
  • Save germ13/9d2644c0926fad9dd90d to your computer and use it in GitHub Desktop.
Save germ13/9d2644c0926fad9dd90d to your computer and use it in GitHub Desktop.
Creates a buffer on the bottom 3rd of the frame. The buffers is an Emacs Eshell, that opens up to the current working directory of the current buffer. Borrowed from http://www.howardism.org/Technical/Emacs/eshell-fun.html
(defun eshell-here ()
"Opens up a new shell in the directory associated with the current buffer's file. The eshell is renamed to match that directory to make multiple eshell windows easier."
(interactive)
(let* ((parent (if (buffer-file-name)
(file-name-directory (buffer-file-name))
default-directory))
(height (/ (window-total-height) 3))
(name (car (last (split-string parent "/" t)))))
(split-window-vertically (- height))
(other-window 1)
(eshell "new")
(rename-buffer (concat "*eshell: " name "*"))
(insert (concat "ls"))
(eshell-send-input)))
(global-set-key (kbd "C-!") 'eshell-here)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment