diff options
| author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-11-04 16:44:28 +0000 |
|---|---|---|
| committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-11-04 16:44:28 +0000 |
| commit | 58cc74e09647150594c03bd7ddcf717890ebdcb6 (patch) | |
| tree | 86f6353b54890113894052d776b0f47860e9706a /Emacs/.config/emacs/elisp | |
| parent | 088ce4a8656ae8ae882c4c8bb043b9792895964a (diff) | |
| download | dotfiles-58cc74e09647150594c03bd7ddcf717890ebdcb6.tar.gz dotfiles-58cc74e09647150594c03bd7ddcf717890ebdcb6.tar.bz2 dotfiles-58cc74e09647150594c03bd7ddcf717890ebdcb6.zip | |
eshell: Setup some helper functions in eshell-additions, move bindings to there.
- A helper function to instantly perform commands
- eshell-goto-latest-prompt to remove any artifacts when performing
these instant commands
Bindings needed to be moved over to that section cos they utilise
these helpers.
Diffstat (limited to 'Emacs/.config/emacs/elisp')
| -rw-r--r-- | Emacs/.config/emacs/elisp/eshell-additions.el | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/Emacs/.config/emacs/elisp/eshell-additions.el b/Emacs/.config/emacs/elisp/eshell-additions.el index e1225b4..cd068df 100644 --- a/Emacs/.config/emacs/elisp/eshell-additions.el +++ b/Emacs/.config/emacs/elisp/eshell-additions.el @@ -28,23 +28,41 @@ (autoload #'eshell/echo "eshell") (autoload #'eshell/send-input "eshell") +;; General helpers +(defun eshell-goto-latest-prompt () + "Move point to the most recent eshell prompt and clear anything before it." + (interactive) + (goto-char (point-max)) + (eshell-bol) + (delete-region (point) (point-max))) + +(defun eshell-send-command (cmd) + (interactive "sCommand: ") + (eshell-goto-latest-prompt) + (insert cmd) + (eshell-send-input)) + ;; Aliases (defun eshell/goto (&rest args) - "Use `read-directory-name' to change directories" - (let* ((name (read-file-name "Choose file: ")) + "Use `read-file-name' to change directories" + (let* ((name (read-file-name "Choose file: " (thing-at-point 'filename t))) (dir (file-name-directory name))) + (eshell-goto-latest-prompt) (eshell/cd (list dir)) (if (not (file-directory-p name)) (find-file name)))) (defun eshell/project-root (&rest args) "Change to directory `project-root'" - (if (project-current) - (eshell/cd (list (project-root (project-current)))) + (cond + ((project-current) + (eshell-goto-latest-prompt) + (eshell/cd (list (project-root (project-current))))) + (t (setq eshell-last-command-status 1) (eshell/echo (format "[%s]: No project in current directory" - (propertize "Error" 'font-lock-face '(:foreground "red")))))) + (propertize "Error" 'font-lock-face '(:foreground "red"))))))) (defun eshell/sudo-switch (&rest args) "Switch to and from administrative (sudo) mode in Eshell. @@ -57,7 +75,7 @@ Uses tramp to figure out if we're in sudo mode or not. " ((string= user "root") (eshell/cd (file-remote-p default-directory 'localname)))))) -;; Additional functions +;; +eshell/open and +eshell/at-cwd (defun +eshell/--current-instances () (cl-loop for buffer being the buffers if (with-current-buffer buffer |
