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.

View in manual

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."
  (interactive)
  (require 'comint)
  (let* ((default-directory (project-root (project-current t)))
         (default-project-shell-name (project-prefixed-buffer-name "shell"))
         (shell-buffer (get-buffer default-project-shell-name)))
    (if (and shell-buffer (not current-prefix-arg))
        (if (comint-check-proc shell-buffer)
            (pop-to-buffer shell-buffer (bound-and-true-p display-comint-buffer-action))
          (shell shell-buffer))
      (shell (generate-new-buffer-name default-project-shell-name)))))