> From: Sivaram Neelakantan <nsivaram....@gmail.com> > Date: Fri, 04 Oct 2024 18:40:15 +0530 > User-Mail-Address: nsivaram....@gmail.com > > on GNU Emacs 29.4 (build 2, x86_64-w64-mingw32) of 2024-07-05, when I > invoke M-x shell, I get garbled characters which seem to go away with > with setting PS1; see below > > --8<---------------cut here---------------start------------->8--- > bash: cannot set terminal process group (-1): Inappropriate ioctl for device > bash: no job control in this shell > ]0;/c/gnu/emacs-29.4/bin > agam@agamam /c/gnu/emacs-29.4/bin > $ echo $PS1 > \[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[35m\]$MSYSTEM\[\e[0m\] > \[\e[33m\]\w\[\e[0m\]\n\$ > ]0;/c/gnu/emacs-29.4/bin > agam@agamam /c/gnu/emacs-29.4/bin > $ export PS1="\e[0;31m[\u@\h \W]\$ \e[m " > [agam@agamam bin]$ pwd > /c/gnu/emacs-29.4/bin > [agam@agamam bin]$ > --8<---------------cut here---------------end--------------->8--- > > So, I try to plug in the above PS1 in different places and it doesn't to > seem to get read at all. I've tried ~/.bashrc which points to > c:/Users/agam/AppData/Roaming and ~/.emacs_bash in the same place. I've > also tried .bashrc in mys home directory but it doesn't be seem be read > > --8<---------------cut here---------------start------------->8--- > > (setenv "BASH_ENV" "~/.bashrc") > (setq explicit-shell-file-name "C:/msys64/usr/bin/bash.exe") > (setq shell-file-name "C:/msys64/usr/bin/bash.exe") > (setenv "SHELL" shell-file-name) > (setq shell-command-switch "-ic") > (add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m) > (autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t) > (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) > --8<---------------cut here---------------end--------------->8--- > > What am I doing incorrectly? And where should the PS1 be plugged in? > And is there a way to see which config files are being sourced when M-x > shell is invoked?
The problem is that you are using the MSYS Bash, and that Windows doesn't support the ioctl calls required for "M-x shell" to work with Bash. Emacs on Windows uses pipes to communicate with sub-processes, so any Bash settings that are meant for interactive use will likely not work in "M-x shell", because pipes are not terminal devices. You could try customizing explicit-bash-args, maybe it will help.