mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-13 00:17:25 +00:00
Make help
and fish_config
work on Chrome OS
When `fish` is running in the Chrome OS Linux VM (Crostini), both `help` and `fish_config` opened a "file not found" page. That is because on Crostini, `BROWSER` is usually set to `garcon-url-handler`, which opens URLs in the host OS Chrome browser. That browser lacks access to the Linux file system. This commit fixes these commands. `help` now opens the URL on www.fishshell.com. `fish_config` now opens the URL for the server it starts. Previously, it opened a local file that redirects to the same URL. In the case of `help`, the situation could be improved further by starting a web server to serve help. I don't know of another way to access `/share/fish` from outside the VM without user intervention, and I think that might be a part of the security model for the Crostini VM. It's hard to write a test for this. I checked that `help math`, `python2 webconfig.py`, and `python3 webconfig.py` work on my machine running in Crostini.
This commit is contained in:
parent
8a07db8e8f
commit
f725cd402d
3 changed files with 23 additions and 2 deletions
|
@ -15,6 +15,7 @@ Scripting improvements
|
|||
|
||||
Interactive improvements
|
||||
------------------------
|
||||
- ``help`` and ``fish_config`` no longer open to a "Your file couldn't be accessed" page when fish is running in a Chrome OS Crostini Linux VM and URLs are opened in Chrome running outside the VM.
|
||||
|
||||
New or improved bindings
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
@ -142,12 +142,20 @@ function help --description 'Show help for the fish shell'
|
|||
set fish_help_page "index.html#$fish_help_item"
|
||||
end
|
||||
|
||||
# In Crostini Chrome OS Linux, the default browser opens URLs in Chrome running outside the
|
||||
# linux VM. This browser does not have access to the Linux filesystem. This uses Garcon, see e.g.
|
||||
# https://chromium.googlesource.com/chromiumos/platform2/+/master/vm_tools/garcon/#opening-urls
|
||||
# https://source.chromium.org/search?q=garcon-url-handler
|
||||
string match -q '*garcon-url-handler*' $fish_browser[1]
|
||||
and set -l chromeos_linux_garcon
|
||||
|
||||
set -l page_url
|
||||
if test -f $__fish_help_dir/index.html
|
||||
if test -f $__fish_help_dir/index.html; and not set -lq chromeos_linux_garcon
|
||||
# Help is installed, use it
|
||||
set page_url file://$__fish_help_dir/$fish_help_page
|
||||
|
||||
# For Windows (Cygwin, msys2 and WSL), we need to convert the base help dir to a Windows path before converting it to a file URL
|
||||
# For Windows (Cygwin, msys2 and WSL), we need to convert the base
|
||||
# help dir to a Windows path before converting it to a file URL
|
||||
# but only if a Windows browser is being used
|
||||
if type -q cygpath
|
||||
and string match -qr '(cygstart|\.exe)(\s+|$)' $fish_browser[1]
|
||||
|
|
|
@ -71,6 +71,16 @@ def is_termux():
|
|||
return "com.termux" in os.environ["PATH"] and find_executable("termux-open-url")
|
||||
|
||||
|
||||
def is_chromeos_garcon():
|
||||
""" Return whether we are running in Chrome OS and the browser can't see local files """
|
||||
# In Crostini Chrome OS Linux, the default browser opens URLs in Chrome
|
||||
# running outside the linux VM. This browser does not have access to the
|
||||
# Linux filesystem. This uses Garcon, see for example
|
||||
# https://chromium.googlesource.com/chromiumos/platform2/+/master/vm_tools/garcon/#opening-urls
|
||||
# https://source.chromium.org/search?q=garcon-url-handler
|
||||
return "garcon-url-handler" in webbrowser.get().name
|
||||
|
||||
|
||||
# Disable CLI web browsers
|
||||
term = os.environ.pop("TERM", None)
|
||||
# This import must be done with an empty $TERM, otherwise a command-line browser may be started
|
||||
|
@ -1549,6 +1559,8 @@ def runThing():
|
|||
sys.exit(-1)
|
||||
elif is_termux():
|
||||
subprocess.call(["termux-open-url", url])
|
||||
elif is_chromeos_garcon():
|
||||
webbrowser.open(url)
|
||||
else:
|
||||
webbrowser.open(fileurl)
|
||||
|
||||
|
|
Loading…
Reference in a new issue