new-term

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

new-term.el (1361B)


      1 ;;; new-term.el --- A way to spawn multiple emacs terminals -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright © 2022 Erik Oosting
      4 
      5 ;; Author: Erik Oosting <crazazy@tilde.cafe>
      6 ;; Keywords: application-launcher, misc
      7 ;; URL: https://crazazy.tilde.cafe/emenu.git/log.html
      8 
      9 ;;; License:
     10 ;; This file comes with the MIT license, and without any warranty whatsoever
     11 ;; You can do with this stuff whatever you want to, but just remember
     12 ;; to put me in the footnote :D. Would be nice at least
     13 
     14 ;;; Commentary:
     15 ;; A simple way to have multiple terminals in emacs. just type "M-x new-term"
     16 ;; to start a new session
     17 
     18 ;;; Code:
     19 
     20 ;;;###autoload
     21 (defun new-term (program)
     22   "start a new terminal emulator in a new buffer"
     23   (interactive (list (read-from-minibuffer "Run program: "
     24                                            (or explicit-shell-file-name
     25                                                (getenv "ESHELL")
     26                                                shell-file-name))))
     27   (let* ((term-list (seq-filter
     28                     (lambda (s) (string-match-p "terminal" (buffer-name s)))
     29                     (buffer-list)))
     30          (term-num (number-to-string (length term-list))))
     31     (set-buffer (make-term (concat "terminal-" term-num) program))
     32     (term-mode)
     33     (term-char-mode)
     34     (switch-to-buffer (concat "*terminal-" term-num "*"))))
     35 ;;; new-term.el ends here