Windows,Emacs,Git Bash和shell命令 [英] Windows, Emacs, Git Bash, and shell-command
问题描述
Windows 7. Emacs 24.3.1。 Git 1.8.1.msysgit.1。我的等效的.emacs文件中有以下内容:
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)))
当我想要执行 Mx shell :我可以弹出一个shell并输入ls。
This works great when I want to do M-x shell: I can pop open a shell and type "ls".
然而,命令失败。当我尝试通过shell命令运行ls(它应该在* Shell命令输出*缓冲区中打印输出,根据 ch f shell命令),我得到一个错误消息:
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:
搜索程序:权限被拒绝,bash
"Searching for program: permission denied, bash"
Google上有一些非常旧的建议调用过程和StackOverflow上有关使Shell在Emacs中工作的许多问题。请注意,Mx shell 非常好,我想要的是shell命令。
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.
(原因: https://github.com/donkirkby/live-py-plugin#installing-the-emacs-mode )
推荐答案
尝试将两个变量设置为指向相同的可执行文件,并确保路径在 exec-path
:
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")
这篇关于Windows,Emacs,Git Bash和shell命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!