help-emacs-windows
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[h-e-w] Using both bash and cmd shells under emacs - solution


From: Underwood, Jonathan
Subject: [h-e-w] Using both bash and cmd shells under emacs - solution
Date: Thu, 11 Oct 2001 19:53:14 -0400

Hi

After much playing about, the following is the new stuff i've lfigured out
about using both bash and cmd under emacs 20.7.3. I'm posting this because
it may be of use to someone someday, maybe, possibly. Apologies if this is
trivial and spammy to anyone, but i looked extensively thru' the archives
and failed to find the information i needed.

Two parts - relevant part of .emacs startup file, and after that, a couple
of things from .bashrc of relevance. Have attempted to provide some notes on
what's going on.

;========================
;; Cygwin + cmd as shell (.emacs)
;======================== 
;; The problem with using a command like 
;; (setenv "PATH" (concat "C:/usr/cygwin/bin;" (getenv "PATH"))) 
;; is this adds the cygwin bin direcotry to the PATH, which may cause
confusion
;; if one switches to another shell. It is far better to set the BASH_ENV to
;; point to a file which sets the path for a non-interactive shell (which
;; doesn't read startup files - see man bash) for running commands like make
;; etc.

;; As described in shell.el setting explicit-shell-name to "name" creates a
;; variable explicit-name-args which are passed to the shell command when an
;; explicit shell is requested (M-x shell command). This starts an
interactive
;; shell.

;; When bash is opened non-interactively by comint.el no startup files are
read,
;; and so the path is not set. However, bash looks at the environment
variable
;; BASH_ENV and reads that file prior to running whichever command, so this
file
;; may be used to set the path.

;; Also note that aliasing ls to ls --color in bash startup files will
royally
;; screw up the shell buffer.

;; Below are two functions for switching the shell type. Note also that the
;; shell used by auctex may be independently set using the variables
TeX-shell
;; and TeX-shell-command-option _after_ auctex has been loaded.

(setq exec-path (append (list "c:/usr/cygwin/bin") exec-path))
(setenv "BASH_ENV" "~/.bashrc") ; file read for the noninteractive shell
(setq Info-directory-list (append
 
Info-default-directory-list'("c:/cygwin/usr/info")))
(setq process-coding-system-alist '(("bash" . undecided-unix)))

(defun set-shell-bash ()
  "Set the default shell to be bash."
  (interactive)
  (setq w32-quote-process-args ?\")
  (setq shell-file-name "bash")
  (setenv "SHELL" shell-file-name) 
  (setq explicit-shell-file-name shell-file-name) 
  (setq explicit-bash-args '("--login" "-i")) ; see shell.el 
  (setq shell-command-switch "-c")
  (add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m) 
  (message "Shell is now bash")
  )

(defun set-shell-cmd ()
  "Set the default shell to be cmd."
  (interactive)
  (setq w32-quote-process-args t)
  (setq shell-command-switch "/c")
  (setq shell-file-name "cmd")
  (setq explicit-shell-file-name shell-file-name)
  (setenv "SHELL" shell-file-name) 
  (setq comint-process-echoes t)
  (message "Shell is now cmd")
  )


==================
>From .bashrc
==================
# correct way to set prompt for emacs compilation buffer etc (see emacs
manual).
if [ "${PS1+set}" = set ]
    then export PS1='$ '
fi

# set path - do this here so that eg. when emacs starts a non interactive
shell,
# as long as BASH_ENV points to this file, the path is still set.
export PATH="/usr/local/bin:/usr/bin:/bin:$PATH";






reply via email to

[Prev in Thread] Current Thread [Next in Thread]