1

I've try to follow this question and sulution Git Bash in emacs on Windows I have this function:

(prefer-coding-system 'utf-8) (defun git-bash () (interactive) (let ((explicit-shell-file-name "C:/Users/jankiewj/AppData/Local/Programs/Git/git-bash.exe") (explicit-bash.exe-args '("--login" "-i"))) (call-interactively 'shell))) 

but when I execute this function, git bash is created in new system window instead of Emacs window. So I don't even get the same error as OP.

I've also tried to run ansi-term but got error:

apply: Spawning child process: Invalid argument 

How can I make git bash work inside Emacs window on MS Windows?

1
  • You could try running something like msys2.org and running both emacs and git (and bash) inside of it. It should make spawning shells easier. Commented Jul 2, 2018 at 16:11

1 Answer 1

1

Follow the answer provided in: Git Bash in emacs on Windows

Most importantly, make sure that you are using bin/bash.exe rather than git-bash.exe.

You're good to use the defun apprach that you have in your question to make it work with an emacs command other than M-x shell (M-x git-bash in your case).

If you just want to change the shell that M-x shell uses, then you only need your init.el to have something like:

(prefer-coding-system 'utf-8) (setq explicit-shell-file-name "C:/Program Files/Git/bin/bash.exe") (setq explicit-bash.exe-args '("--login" "-i")) 

The last important bit is that your ~/.bashrc (or other bash config file) should define a simpler PS1 for your prompt. This was the example given in the other answer:

if [ -n "$INSIDE_EMACS" ]; then export PS1='\[\033[32m\]\u@\h \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ ' fi 
2
  • 1
    I don't get the error anymore but I can't interact with the terminal, enter is not sent to terminal. I probably need to ask another question. Commented Nov 22, 2018 at 9:48
  • I've asked here Enter not sent to bash in shell buffer on Windows Commented Nov 22, 2018 at 9:55

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.