add function to determine windows wsl and a function to open links in Windows web browser if wsl is used

This commit is contained in:
2021-02-18 14:36:47 +01:00
parent 0e987ba777
commit 64234286f0
2 changed files with 21 additions and 7 deletions

View File

@@ -152,18 +152,14 @@
but it's REALLY SLOW when you have buffers that are visiting
remote files. And despite its documentation, it does NOT ignore
those files, if you're using windows, and the file name begins
with a drive letter and a colon.")
)
(setq global-auto-revert-non-file-buffers t)
)
)
with a drive letter and a colon."))
(setq global-auto-revert-non-file-buffers t)))
(setq revert-without-query '(".*"))
(use-package uniquify
:defer t
:config
(setq uniquify-buffer-name-style 'forward) ;; forward: bar/mumble/name insead of post-forward-angle-brackets: name<bar/mumble>
)
(setq uniquify-buffer-name-style 'forward)) ;; forward: bar/mumble/name insead of post-forward-angle-brackets: name<bar/mumble>
;; overwrite selected text
(delete-selection-mode t)
@@ -217,6 +213,16 @@ with a drive letter and a colon.")
;; gravatars from magit use this to store their cache
(setq url-configuration-directory (concat user-cache-directory "url/"))
;; https://adam.kruszewski.name/2017/09/emacs-in-wsl-and-opening-links/
;; For WSL open links in Windows web browser of choice
(when running-on-windows-wsl
(let ((cmd-exe "/mnt/c/Windows/System32/cmd.exe")
(cmd-args '("/c" "start")))
(when (file-exists-p cmd-exe)
(setq browse-url-generic-program cmd-exe
browse-url-generic-args cmd-args
browse-url-browser-function 'browse-url-generic))))
(setq bookmark-default-file (concat user-cache-directory "bookmarks"))
(use-package transient

View File

@@ -41,6 +41,14 @@
(memq system-type '(windows-nt cygwin32 cygwin))
"Non-nil if and only if we're running on Windows.
Both Win32 and Cygwin count.")
;; https://stackoverflow.com/questions/60922620/shell-script-to-check-if-running-in-windows-when-using-wsl
(defvar running-on-windows-wsl
(string-equal
(replace-regexp-in-string
"[ \n]+$" ""
(shell-command-to-string
"uname -a | sed -n 's/.*\\( *Microsoft *\\).*/\\1/ip'"))
"Microsoft"))
(setq user-emacs-directory "~/.config/emacs/")
(defconst user-cache-directory
(file-name-as-directory (concat user-emacs-directory ".cache"))