Created
May 6, 2015 13:52
-
-
Save poppingtonic/ae1bf17d44c707d8cf95 to your computer and use it in GitHub Desktop.
Open eshell in the current directory
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. 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) | |
(defun eshell/!x () | |
(insert "exit") | |
(eshell-send-input) | |
(delete-window)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
C-! (Ctrl+Shift+1) opens eshell in the current directory.