How to determine operating system in elisp?

前端 未结 7 804
一个人的身影
一个人的身影 2021-01-30 19:22

How do I programmatically determine which OS Emacs is running under in ELisp?

I would like to run different code in .emacs depending on the OS.

7条回答
  •  悲&欢浪女
    2021-01-30 20:00

    Now there is also Linux Subsystem for Windows (bash under Windows 10) where system-type is gnu/linux. To detect this system type use:

    (if
        (string-match "Microsoft"
             (with-temp-buffer (shell-command "uname -r" t)
                               (goto-char (point-max))
                               (delete-char -1)
                               (buffer-string)))
        (message "Running under Linux subsystem for Windows")
        (message "Not running under Linux subsystem for Windows")
      )
    

提交回复
热议问题