Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows, Emacs, Git Bash, and shell-command

Windows 7. Emacs 24.3.1. Git 1.8.1.msysgit.1. I have the following in my equivalent .emacs file:

(if (equal system-type 'windows-nt)
    (progn (setq explicit-shell-file-name
                 "C:/Program Files (x86)/Git/bin/sh.exe")
           (setq shell-file-name "bash")
           (setq explicit-sh.exe-args '("--login" "-i"))
           (setenv "SHELL" shell-file-name)
           (add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)))

This works great when I want to do M-x shell: I can pop open a shell and type "ls".

However, M-x shell-command is failing. When I try to run "ls" via shell-command (which should print its output in the *Shell Command Output* buffer, according to C-h f shell-command), I get a single error message:

"Searching for program: permission denied, bash"

There are some very old suggestions on the Google about call-process and many questions on StackOverflow about getting the shell to work in Emacs. Please note that M-x shell works great, and what I'd like to work is shell-command.

(Reason: https://github.com/donkirkby/live-py-plugin#installing-the-emacs-mode)

like image 222
Ahmed Fasih Avatar asked May 21 '13 18:05

Ahmed Fasih


People also ask

How do I open a git bash shell?

Open the Start menu by clicking on the Windows icon and typing “Git Bash” into the search bar. The icon for Git Bash and the words “Git Bash Desktop App” will appear. Click on the icon or the words “Git Bash Desktop App” to open Git Bash.

How do I run git bash from command line?

Launch Git Bash console by clicking on the Start button, type git, and click on Git Bash. 2. Run the below git config command to add your name ( YourName ) as your git username ( user.name ). The git config command administers configuration variables that control how Git looks and operates.

Does git bash have vi?

Git includes Vi in its Git Bash shell on Windows through MinGW64.


1 Answers

Try setting both variables to point to the same executable and make sure the path is in exec-path:

(setq explicit-shell-file-name
      "C:/Program Files (x86)/Git/bin/bash.exe")
(setq shell-file-name explicit-shell-file-name)
(add-to-list 'exec-path "C:/Program Files (x86)/Git/bin")
like image 168
Alex Vorobiev Avatar answered Oct 13 '22 02:10

Alex Vorobiev