Browse files

make shell cd to the right place like eshell used to

  • Loading branch information...
1 parent f5a1ea4 commit 25db0ca8a9eb14571bce3fc67eae3fd6b1571fc6 @langmartin committed Sep 13, 2012
Showing with 15 additions and 2 deletions.
  1. +15 −2 rc-eshell.el
View
17 rc-eshell.el
@@ -16,8 +16,21 @@
(t
(eshell nil))))
-(global-set-key (kbd "H-s") 'eshell-focus-or-create)
+;; (global-set-key (kbd "H-s") 'eshell-focus-or-create)
-(global-set-key (kbd "H-s") 'shell)
+(defun shell-focus-or-create (prefix)
+ (interactive "P")
+ (cond (prefix
+ (eshell prefix))
+ ((bufferp (get-buffer "*shell*"))
+ (let ((dir default-directory))
+ (switch-to-buffer "*shell*")
+ (unless (equal dir default-directory)
+ (insert "cd " dir)
+ (comint-send-input))))
+ (t
+ (eshell nil))))
+
+(global-set-key (kbd "H-s") 'shell-focus-or-create)
(provide 'rc-eshell)

0 comments on commit 25db0ca

Please sign in to comment.