我正在使用空间数据库,我想根据我所在的平台(platform),为组织模式的声明不同的路径()。
例如,如果我在Linux中,我希望路径是~/orgs,但是如果我在windows,则路径应该是D:\orgs\。
有检查当前平台的变量吗?
发布于 2021-08-02 06:50:06
解决方案之一(感谢spacemacs的gitter网站中的@dalanicolai和@milochadam提供了所有帮助)是在 user-init ()中声明了您的状态--例如,我声明了两个全局变量:snippet_path和org_path,它们将得到不同的值取决于平台(Linux/windows):
(defun dotspacemacs/user-init ()
;; ... other stuff
(if (or (equal system-type 'cygwin) (equal system-type 'windows-nt) (equal system-type 'ms-dos))
;; if we are in windows
(progn
(setq snippet_path "e:/home/snippets")
(setq org_path "d:/org-mode/todo.org")
)
;; else if (we are in linux)
(progn
(setq snippet_path "/home/ghost/spacemacs/snippets")
(setq org_path "d:/org-mode/todo.org")
)
)
;; ... other stuff
)现在,我们可以在任何我们喜欢的地方使用这两个变量,例如在我们的层内部吐露:
(auto-completion :variables
auto-completion-private-snippets-directory snippet_path
)发布于 2021-07-28 20:34:37
使用命令
systeminfo _ findstr /B /C:"OS名称“/C:"OS版本”将返回OS名称和版本。在运行命令后将其放入变量中,然后进行一些比较测试。
请参阅此链接:https://www.windows-commandline.com/find-windows-os-version-from-command/
https://stackoverflow.com/questions/68566943
复制相似问题