Up: How do I use a shell in Emacs?   [Contents][Index]

7.7.1 bash

Cygwin bash is a popular shell for use with Emacs. To use bash as the default shell in Emacs, you can place the following in your init file:

(defun my-shell-setup ()
  "For Cygwin bash under Emacs 20"
  (setq comint-scroll-show-maximum-output 'this)
  (make-variable-buffer-local 'comint-completion-addsuffix))
  (setq comint-completion-addsuffix t)
  ;; (setq comint-process-echoes t) ;; reported that this is no longer needed
  (setq comint-eol-on-send t)
  (setq w32-quote-process-args ?\")

(add-hook 'shell-mode-hook 'my-shell-setup)

WARNING: Some versions of bash set and use the environment variable PID. For some as yet unknown reason, if PID is set and Emacs passes it on to bash subshells, bash dies (Emacs can inherit the PID variable if it’s started from a bash shell). If you clear the PID variable in your init file, you should be able to continue to use bash as your subshell:

    (setenv "PID" nil)