From 0979b9a98bfd81bcee9339a7e9e666b3c44184a2 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Sat, 2 Nov 2024 21:28:17 +0100 Subject: [PATCH] help: Print external URL if no browser was found This is nicer when you use fish over ssh, and that system does not have a browser. But the system where your terminal is has one, and so now you can just click the link. --- share/functions/help.fish | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/share/functions/help.fish b/share/functions/help.fish index 06b793bf3..031a7d0d0 100644 --- a/share/functions/help.fish +++ b/share/functions/help.fish @@ -95,16 +95,11 @@ function help --description 'Show help for the fish shell' end end - if not set -q fish_browser[1] - printf (_ '%s: Could not find a web browser.\n') help >&2 - printf (_ 'Please try `BROWSER=some_browser help`, `man fish-doc`, or `man fish-tutorial`.\n\n') >&2 - return 1 - end - # In Cygwin, start the user-specified browser using cygstart, # only if a Windows browser is to be used. if type -q cygstart - if test $fish_browser != cygstart + if test "$fish_browser" != cygstart + and set -q fish_browser[1] and not command -sq $fish_browser[1] # Escaped quotes are necessary to work with spaces in the path # when the command is finally eval'd. @@ -206,6 +201,13 @@ function help --description 'Show help for the fish shell' set need_trampoline end + if not set -q fish_browser[1] + printf (_ '%s: Could not find a web browser.\n') help >&2 + printf (_ 'Please try `BROWSER=some_browser help`, `man fish-doc`, or `man fish-tutorial`.\n\n') >&2 + printf (_ 'Or open %s in your browser of choice.\n') $ext_url >&2 + return 1 + end + if set -q need_trampoline[1] # If string replace doesn't replace anything, we don't actually need a # trampoline (they're only needed if there's a fragment in the path)