Last active
December 10, 2016 11:36
-
-
Save howardabrams/9245265 to your computer and use it in GitHub Desktop.
A function for creating small, temporary eshell buffers that will be "somewhat associated" with a particular buffer (since it is named after the directory that file is in).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun eshell-here () | |
"Opens up a new shell in the directory associated with the current buffer's file." | |
(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