Function: project-shell
project-shell is an autoloaded, interactive and byte-compiled function
defined in project.el.gz.
Signature
(project-shell)
Documentation
Start an inferior shell in the current project's root directory.
If a buffer already exists for running a shell in the project's root,
switch to it. Otherwise, create a new shell buffer.
With C-u (universal-argument) prefix arg, create a new inferior shell buffer even
if one already exists.
With numeric prefix arg, switch to the session with that number, or
create it if it doesn't already exist.
Probably introduced at or before Emacs version 28.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/project.el.gz
;;;###autoload
(defun project-shell ()
"Start an inferior shell in the current project's root directory.
If a buffer already exists for running a shell in the project's root,
switch to it. Otherwise, create a new shell buffer.
With \\[universal-argument] prefix arg, create a new inferior shell buffer even
if one already exists.
With numeric prefix arg, switch to the session with that number, or
create it if it doesn't already exist."
(interactive)
(require 'comint)
(let* ((default-directory (project-root (project-current t)))
(base-name (project-prefixed-buffer-name "shell"))
(shell-buffer-name
(cond ((numberp current-prefix-arg)
(format "%s<%d>" base-name current-prefix-arg))
(current-prefix-arg
(generate-new-buffer-name base-name))
(t base-name)))
(shell-buffer (get-buffer shell-buffer-name)))
(if (and shell-buffer (not current-prefix-arg))
(if (comint-check-proc shell-buffer)
(pop-to-buffer shell-buffer (append display-buffer--same-window-action
'((category . comint))))
(shell shell-buffer))
(shell shell-buffer-name))))