Add command to switch to a buffer’s directory in eshell
This commit is contained in:
parent
09513419bc
commit
897ab273a0
1 changed files with 16 additions and 1 deletions
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
;; Author: Tom Willemse <tom@ryuslash.org>
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
||||||
;; Keywords: local
|
;; Keywords: local
|
||||||
;; Version: 2020.0908.002925
|
;; Version: 2020.1026.133507
|
||||||
;; Package-Requires: (eshell-fringe-status esh-autosuggest xterm-color eshell-syntax-highlighting)
|
;; Package-Requires: (eshell-fringe-status esh-autosuggest xterm-color eshell-syntax-highlighting)
|
||||||
|
|
||||||
;; This program is free software; you can redistribute it and/or modify
|
;; This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
(require 'eshell)
|
(require 'eshell)
|
||||||
|
|
||||||
|
(require 'em-dirs)
|
||||||
(require 'em-prompt)
|
(require 'em-prompt)
|
||||||
(require 'esh-autosuggest)
|
(require 'esh-autosuggest)
|
||||||
(require 'xterm-color)
|
(require 'xterm-color)
|
||||||
|
@ -67,6 +68,18 @@
|
||||||
"Set ‘company-posframe-active-map’ to ‘esh-autosuggest-active-map’."
|
"Set ‘company-posframe-active-map’ to ‘esh-autosuggest-active-map’."
|
||||||
(setq-local company-posframe-active-map 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-before-prompt-hook #'oni-eshell--set-xterm-variables)
|
||||||
(add-hook 'eshell-first-time-mode-hook #'oni-eshell--set-eshell-C-d)
|
(add-hook 'eshell-first-time-mode-hook #'oni-eshell--set-eshell-C-d)
|
||||||
(add-hook 'eshell-load-hook #'oni-eshell--disable-ansi-color-handling)
|
(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)
|
(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)
|
(when (display-graphic-p)
|
||||||
(add-hook 'eshell-mode-hook 'eshell-fringe-status-mode))
|
(add-hook 'eshell-mode-hook 'eshell-fringe-status-mode))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue