From a89353eeb8727e31baa6093817be37583a34c41e Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sat, 22 Jun 2024 02:26:08 +0100 Subject: Tons of changes --- Emacs/.config/emacs/elisp/eshell-additions.el | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Emacs/.config/emacs/elisp/eshell-additions.el') diff --git a/Emacs/.config/emacs/elisp/eshell-additions.el b/Emacs/.config/emacs/elisp/eshell-additions.el index 94c948f..d56dc99 100644 --- a/Emacs/.config/emacs/elisp/eshell-additions.el +++ b/Emacs/.config/emacs/elisp/eshell-additions.el @@ -53,5 +53,30 @@ (eshell/cd dir) (eshell-send-input)))) +(defun +eshell/--current-instances () + (cl-loop for buffer being the buffers + if (with-current-buffer buffer + (eq major-mode 'eshell-mode)) + collect + (cons (buffer-name buffer) buffer))) + +(defun +eshell/open (&optional ARG) + "If no arg is given, run EShell as per usual. +If an arg is given, then interactively open a new Eshell instance +or a currently opened one, naming it in the process." + (interactive "P") + (if (null ARG) + (eshell) + (let* ((current-instances (+eshell/--current-instances)) + (answer (completing-read "Enter name: " (mapcar #'car current-instances))) + (result (assoc answer current-instances))) + (cond + (result (switch-to-buffer (cdr result))) + ((not (string= answer "")) + (let ((eshell-buffer-name (format "*%s-eshell*" answer))) + (eshell))) + (t + (eshell)))))) + (provide 'eshell-additions) ;;; eshell-additions.el ends here -- cgit v1.2.3-13-gbd6f