From 812caeb3143a2c4e413c060425518a28df17b2ab Mon Sep 17 00:00:00 2001 From: Erik Oosting Date: Tue, 20 Sep 2022 10:00:35 +0200 Subject: initial commit --- new-term.el | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 new-term.el (limited to 'new-term.el') diff --git a/new-term.el b/new-term.el new file mode 100644 index 0000000..53bb154 --- /dev/null +++ b/new-term.el @@ -0,0 +1,35 @@ +;;; new-term.el --- A way to spawn multiple emacs terminals -*- lexical-binding: t; -*- + +;; Copyright © 2022 Erik Oosting + +;; Author: Erik Oosting +;; Keywords: application-launcher, misc +;; URL: https://crazazy.tilde.cafe/emenu.git/log.html + +;;; License: +;; This file comes with the MIT license, and without any warranty whatsoever +;; You can do with this stuff whatever you want to, but just remember +;; to put me in the footnote :D. Would be nice at least + +;;; Commentary: +;; A simple way to have multiple terminals in emacs. just type "M-x new-term" +;; to start a new session + +;;; Code: + +;;;###autoload +(defun new-term (program) + "start a new terminal emulator in a new buffer" + (interactive (list (read-from-minibuffer "Run program: " + (or explicit-shell-file-name + (getenv "ESHELL") + shell-file-name)))) + (let* ((term-list (seq-filter + (lambda (s) (string-match-p "terminal" (buffer-name s))) + (buffer-list))) + (term-num (number-to-string (length term-list)))) + (set-buffer (make-term (concat "terminal-" term-num) program)) + (term-mode) + (term-char-mode) + (switch-to-buffer (concat "*terminal-" term-num "*")))) +;;; new-term.el ends here -- cgit 1.4.1-2-gfad0