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.
This commit is contained in:
@@ -30,7 +30,11 @@
|
|||||||
;; Aliases
|
;; Aliases
|
||||||
(defun eshell/goto (&rest args)
|
(defun eshell/goto (&rest args)
|
||||||
"Use `read-directory-name' to change directories"
|
"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)
|
(defun eshell/project-root (&rest args)
|
||||||
"Change to directory `project-root'"
|
"Change to directory `project-root'"
|
||||||
|
|||||||
Reference in New Issue
Block a user