aboutsummaryrefslogtreecommitdiffstats
path: root/oni-eshell.el
diff options
context:
space:
mode:
authorGravatar Tom Willemse2020-10-26 13:36:09 -0700
committerGravatar Tom Willemse2020-10-26 13:36:09 -0700
commit897ab273a0dd6808271ac8e327bc60c3f5a9c22c (patch)
tree41157914f1d64a6e6fa7ddcfabff528923762f3a /oni-eshell.el
parent09513419bcb6fab9c1faa9618ef7e000610bec2a (diff)
downloademacs-config-897ab273a0dd6808271ac8e327bc60c3f5a9c22c.tar.gz
emacs-config-897ab273a0dd6808271ac8e327bc60c3f5a9c22c.zip
Add command to switch to a buffer’s directory in eshell
Diffstat (limited to 'oni-eshell.el')
-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))