aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--oni-eshell.el17
1 files changed, 16 insertions, 1 deletions
diff --git a/oni-eshell.el b/oni-eshell.el
index 6bcadf6..7f8e9ed 100644
--- a/oni-eshell.el
+++ b/oni-eshell.el
@@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
-;; Version: 2020.0908.002925
+;; Version: 2020.1026.133507
;; Package-Requires: (eshell-fringe-status esh-autosuggest xterm-color eshell-syntax-highlighting)
;; This program is free software; you can redistribute it and/or modify
@@ -28,6 +28,7 @@
(require 'eshell)
+(require 'em-dirs)
(require 'em-prompt)
(require 'esh-autosuggest)
(require 'xterm-color)
@@ -67,6 +68,18 @@
"Set ‘company-posframe-active-map’ to ‘esh-autosuggest-active-map’."
(setq-local company-posframe-active-map esh-autosuggest-active-map))
+(defun oni-eshell-goto-buffer-directory (buffer-name)
+ "Change the current directory to the given BUFFER-NAME’s directory."
+ (interactive
+ (list (read-buffer "Switch to buffer’s directory: "
+ nil t (lambda (buf)
+ (let ((b (if (consp buf)
+ (cdr buf)
+ (get-buffer buf))))
+ (buffer-file-name b))))))
+ (eshell/cd (file-name-directory (buffer-file-name (get-buffer buffer-name))))
+ (eshell-reset))
+
(add-hook 'eshell-before-prompt-hook #'oni-eshell--set-xterm-variables)
(add-hook 'eshell-first-time-mode-hook #'oni-eshell--set-eshell-C-d)
(add-hook 'eshell-load-hook #'oni-eshell--disable-ansi-color-handling)
@@ -78,6 +91,8 @@
(add-hook 'esh-autosuggest-mode-hook #'oni-eshell-fix-esh-autosuggest-active-keymap)
+(define-key eshell-mode-map (kbd "C-c b") #'oni-eshell-goto-buffer-directory)
+
(when (display-graphic-p)
(add-hook 'eshell-mode-hook 'eshell-fringe-status-mode))