aboutsummaryrefslogtreecommitdiff
path: root/Emacs/.config/emacs/elisp/eshell-additions.el
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-06-22 02:26:08 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-06-22 02:26:08 +0100
commita89353eeb8727e31baa6093817be37583a34c41e (patch)
tree8267afbbd58d20cad7a330fb7a67393b998cd13e /Emacs/.config/emacs/elisp/eshell-additions.el
parent3ef303fb670303571999aa5b9765ea91ad02ce56 (diff)
downloaddotfiles-a89353eeb8727e31baa6093817be37583a34c41e.tar.gz
dotfiles-a89353eeb8727e31baa6093817be37583a34c41e.tar.bz2
dotfiles-a89353eeb8727e31baa6093817be37583a34c41e.zip
Tons of changes
Diffstat (limited to 'Emacs/.config/emacs/elisp/eshell-additions.el')
-rw-r--r--Emacs/.config/emacs/elisp/eshell-additions.el25
1 files changed, 25 insertions, 0 deletions
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