diff --git a/share/functions/help.fish b/share/functions/help.fish index e04aed808..e42ad81b7 100644 --- a/share/functions/help.fish +++ b/share/functions/help.fish @@ -119,6 +119,11 @@ function help --description 'Show help for the fish shell' set fish_help_page "index.html" end + set -l wsl 0 + if uname -a | string match -qr Microsoft + set wsl 1 + end + set -l page_url if test -f $__fish_help_dir/index.html # Help is installed, use it @@ -150,8 +155,10 @@ function help --description 'Show help for the fish shell' end end + if test $wsl -eq 1 + cmd.exe /c "start $page_url" # If browser is known to be graphical, put into background - if contains -- $fish_browser[1] $graphical_browsers + else if contains -- $fish_browser[1] $graphical_browsers switch $fish_browser[1] case 'htmlview' 'x-www-browser' printf (_ 'help: Help is being displayed in your default browser.\n') diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index 30af43436..b8c0f8007 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -35,6 +35,14 @@ def isMacOS10_12_5_OrLater(): version = platform.mac_ver()[0] return version and LooseVersion(version) >= LooseVersion('10.12.5') +def is_wsl(): + """ Return whether we are running under the Windows Subsystem for Linux """ + if 'linux' in platform.system().lower(): + with open('/proc/version', 'r') as f: + if 'Microsoft' in f.read(): + return True + return False + # Disable CLI web browsers term = os.environ.pop('TERM', None) @@ -1139,6 +1147,8 @@ fileurl = 'file://' + filename print("Web config started at '%s'. Hit enter to stop." % fileurl) if isMacOS10_12_5_OrLater(): subprocess.check_call(['open', fileurl]) +elif is_wsl(): + subprocess.call(['cmd.exe', '/c', "start %s" % url]) else: webbrowser.open(fileurl)