diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-10-16 16:30:13 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-10-16 16:32:51 +0100 |
commit | bec6fdbc3ff96e74b154bdbfd5be8fe2aec1d2f8 (patch) | |
tree | 6adf6ff52908d0eb9f7789148fb2626421ad18a4 | |
parent | 69f916994e2a099603aa15f2ba27b3396cea3787 (diff) | |
download | dotfiles-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.el | 6 |
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'" |