I use vterm as my terminal emulator in Emacs. Out of the box it has an annoying behavior: when you run vterm it opens a vterm session. If you run it again, it opens the same one. I usually have many terminals open at one time so this won’t do.
Here’s some code that creates a new vterm instance and names it uniquely. This provides the behavior you might expect with a “normal” terminal emulator: Run vterm, get a new terminal.
I use Doom Emacs so the mapping part might be different, but the function should work for you as long as vterm is installed.
(defun cb/new-vterm(&optional x)
;; make a new vterm with a unique name
(interactive)
(call-interactively 'vterm)
(rename-uniquely)
)
(map! :leader
:desc "new vterm" "n v"#'cb/new-vterm)
I also just noticed the syntax highlighter on my site doesn’t have elisp or even lisp. Hmmm I need to figure that out.
