1
0
Fork 0

Add command to switch to a buffer’s directory in eshell

This commit is contained in:
Tom Willemse 2020-10-26 13:36:09 -07:00
parent 09513419bc
commit 897ab273a0

View file

@ -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-NAMEs directory."
(interactive
(list (read-buffer "Switch to buffers 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))