Windows, Emacs, Git Bash, and shell-command

后端 未结 3 563
深忆病人
深忆病人 2021-02-09 18:52

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-s         


        
相关标签:
3条回答
  • 2021-02-09 19:21

    Using GitBash you can use the lein script instead of the lein.bat script. Put the lein script into a directory called bin in your user account on windows. GitBash should have that bin directory on its executable PATH, so you can run lein anywhere.

    With this approach you do not need any configuration in Emacs Lisp.

    See my full answer

    0 讨论(0)
  • 2021-02-09 19:33

    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")
    
    0 讨论(0)
  • 2021-02-09 19:48

    I know this is an older question, but I found it while I was searching for help on the same issue, so here's the solution I use for my particular use case, in case it helps someone in the future.

    I sync up my .emacs.d between all computers I use emacs on, which includes both Linux & Windows machines. I inserted this into my init.el file to automatically deal with this issue appropriately in a Windows environment:

    ;; Set Windows-specific preferences if running in a Windows environment.
    (defun udf-windows-setup () (interactive)
      ;; The variable `git-shell-path' contains the path to the `Git\bin'
      ;; file on my system. I install this in
      ;; `%USERPROFILE%\LocalAppInfo\apps\Git\bin'.
      (setq git-shell-path
            (concat (getenv "USERPROFILE") "\\LocalAppInfo\\apps\\Git\\bin"))
      (setq git-shell-executable
            (concat git-shell-path "\\bash.exe"))
      (add-to-list 'exec-path git-shell-path)
      (setenv "PATH"
              (concat git-shell-path ";"
                      (getenv "PATH")))
      (message "Windows preferences set."))
    
    (if (eq system-type 'windows-nt)
        (udf-windows-setup))
    

    Please note that the variable git-shell-path will need to be defined based on where you have git installed on your system. I install it in %USERPROFILE%\LocalAppInfo\apps\Git on the one Windows machine where I use it.

    0 讨论(0)
提交回复
热议问题