diff options
Diffstat (limited to '')
-rw-r--r-- | emacs/custom/fcuny-eshell.el | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/emacs/custom/fcuny-eshell.el b/emacs/custom/fcuny-eshell.el index 53c3f69..2f53988 100644 --- a/emacs/custom/fcuny-eshell.el +++ b/emacs/custom/fcuny-eshell.el @@ -51,6 +51,25 @@ (magit-status (pop args) nil) (eshell/echo)) ;; The echo command suppresses output +(defun fcuny/eshell--open-or-cd (path) + "Cd to PATH if path is a directory ((file-name-directory path) => t), otherwise open PATH via `find-file'." + (interactive) + (if (file-directory-p path) + (progn + (goto-char (point-max)) + (insert (concat "cd " path)) + (eshell-send-input)) + (find-file path))) + +(defun fcuny/eshell-open-file-at-point () + (interactive) + (let ((filename (symbol-name (symbol-at-point)))) + (cond + ((file-readable-p filename) + (fcuny/eshell--open-or-cd filename)) + ((file-readable-p (expand-file-name filename)) + (fcuny/eshell--open-or-cd (expand-file-name filename)))))) + (defun fcuny/shorten-path (path &optional max-len) "Return a potentially trimmed-down version of the directory PATH, replacing parent directories with their initial characters to try to get the character @@ -168,7 +187,9 @@ append to it, while separating multiple outputs with :commands (eshell eshell-command) :bind (("C-c e h" . fcuny/eshell-here) ("C-c e e" . fcuny/eshell-export) - ("C-c r" . counsel-esh-history)) + ("C-c r" . counsel-esh-history) + :map eshell-mode-map + ("C-o" . fcuny/eshell-open-file-at-point)) :custom (eshell-scroll-to-bottom-on-input 'all) (eshell-error-if-no-glob t) |