Skip to content

Instantly share code, notes, and snippets.

@poppingtonic
Created May 6, 2015 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save poppingtonic/ae1bf17d44c707d8cf95 to your computer and use it in GitHub Desktop.
Save poppingtonic/ae1bf17d44c707d8cf95 to your computer and use it in GitHub Desktop.
Open eshell in the current directory
(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))
@poppingtonic
Copy link
Author

C-! (Ctrl+Shift+1) opens eshell in the current directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment