implement eshell-switch-directory-current-buffer bound to \C-cE
Stefan Bund [Tue, 25 Apr 2017 16:10:15 +0000 (18:10 +0200)]
setup/eshell.el

index 66fc6bc..1f836ac 100644 (file)
@@ -9,3 +9,17 @@
   (define-key eshell-mode-map (kbd "<home>") 'eshell-bol))
 
 (add-hook 'eshell-mode-hook 'my-setup-eshell)
+
+(defun eshell-switch-directory-current-buffer ()
+  (interactive)
+  (let ((dir default-directory)
+        (eshell-buffer (get-buffer "*eshell*")))
+    (if (not eshell-buffer)
+        (error "no *eshell* buffer found"))
+    (pop-to-buffer (get-buffer "*eshell*"))
+    (goto-char (point-max))
+    (setq default-directory dir)
+    (insert "\n")
+    (eshell-send-input)))
+
+(global-set-key "\C-cE" 'eshell-switch-directory-current-buffer)