summaryrefslogtreecommitdiffstats
path: root/emacs/.emacs.d/site-lisp/oni-eshell.el
diff options
context:
space:
mode:
Diffstat (limited to 'emacs/.emacs.d/site-lisp/oni-eshell.el')
-rw-r--r--emacs/.emacs.d/site-lisp/oni-eshell.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/emacs/.emacs.d/site-lisp/oni-eshell.el b/emacs/.emacs.d/site-lisp/oni-eshell.el
index 988afd2..e40d893 100644
--- a/emacs/.emacs.d/site-lisp/oni-eshell.el
+++ b/emacs/.emacs.d/site-lisp/oni-eshell.el
@@ -62,6 +62,23 @@ directory in it."
(signal (car err) (cdr err))))))
;;;###autoload
+(defun oni:raise-eshell ()
+ "Start or switch back to `eshell'.
+
+Also change directories to current working directory."
+ (interactive)
+ (let ((dir (file-name-directory
+ (or (buffer-file-name) "~/")))
+ (hasfile (not (eq (buffer-file-name) nil)))
+ (started (and (boundp 'eshell-buffer-name) eshell-buffer-name
+ (buffer-live-p (get-buffer eshell-buffer-name)))))
+ (eshell)
+ (when (and hasfile (eq eshell-process-list nil))
+ (eshell/cd dir)
+ (when started
+ (eshell-reset)))))
+
+;;;###autoload
(defun oni:set-keys-for-eshell ()
"Set some keybindings for `eshell'."
(define-key eshell-mode-map (kbd "C-d") #'oni:eshell-C-d))