Emacs Init: Change Default Shell (PowerShell)

By Xah Lee. Date: . Last updated: .
explicit-shell-file-name
variable. A full path to the default shell started by the command shell

sample init to set it to PowerShell

;; on windows, make pwsh the default shell
;; 2023-09-09
(setq
 explicit-shell-file-name
 (cond
  ((eq system-type 'windows-nt)
   (let ((xlist
          (list
           "~/AppData/Local/Microsoft/WindowsApps/pwsh.exe"
           "C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe"
           )))
     (seq-some (lambda (x) (if (file-exists-p x) x nil)) xlist)))
  (t nil)))

Start PowerShell from Eshell

Alternatively, you can start PowerShell from eshell

  1. Alt+x eshell or Alt+x shell
  2. type powershell or pwsh. (or bash, if you have that installed)
emacs shell 2022-06-02
running cmd.exe and pwsh in emacs, on Microsoft Windows
emacs cmd pwsh 2021-08-28
emacs cmd pwsh 2021-08-28

Shell in Emacs

Emacs on Microsoft Windows