Windows, Emacs, Git Bash, and shell-command

后端 未结 3 560
深忆病人
深忆病人 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: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.

提交回复
热议问题