aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-10-16 16:30:13 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-10-16 16:32:51 +0100
commitbec6fdbc3ff96e74b154bdbfd5be8fe2aec1d2f8 (patch)
tree6adf6ff52908d0eb9f7789148fb2626421ad18a4
parent69f916994e2a099603aa15f2ba27b3396cea3787 (diff)
downloaddotfiles-bec6fdbc3ff96e74b154bdbfd5be8fe2aec1d2f8.tar.gz
dotfiles-bec6fdbc3ff96e74b154bdbfd5be8fe2aec1d2f8.tar.bz2
dotfiles-bec6fdbc3ff96e74b154bdbfd5be8fe2aec1d2f8.zip
Extend +eshell/goto to allow finding files
Instead of only looking at directories, +eshell/goto now works with files. If a directory is selected, set eshell to that directory. If a file is selected, make eshell go to the directory where that file is contained then use find-file.
-rw-r--r--Emacs/.config/emacs/elisp/eshell-additions.el6
1 files changed, 5 insertions, 1 deletions
diff --git a/Emacs/.config/emacs/elisp/eshell-additions.el b/Emacs/.config/emacs/elisp/eshell-additions.el
index b18a8e8..51cdf21 100644
--- a/Emacs/.config/emacs/elisp/eshell-additions.el
+++ b/Emacs/.config/emacs/elisp/eshell-additions.el
@@ -30,7 +30,11 @@
;; Aliases
(defun eshell/goto (&rest args)
"Use `read-directory-name' to change directories"
- (eshell/cd (list (read-directory-name "Directory?: "))))
+ (let* ((name (read-file-name "Choose file: "))
+ (dir (file-name-directory name)))
+ (eshell/cd (list dir))
+ (if (not (file-directory-p name))
+ (find-file name))))
(defun eshell/project-root (&rest args)
"Change to directory `project-root'"