From 5bf7f9c83325a6cb2752e14ca01a574dbeef206e Mon Sep 17 00:00:00 2001
From: Marc Cornellà <hello@mcornella.com>
Date: Fri, 3 Mar 2023 12:34:31 +0100
Subject: fix(lib): use `$BROWSER` in `open_command` if set (#11532)

Fixes #11098
---
 lib/functions.zsh | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'lib/functions.zsh')

diff --git a/lib/functions.zsh b/lib/functions.zsh
index 6e1faa6aa..1d85ea38a 100644
--- a/lib/functions.zsh
+++ b/lib/functions.zsh
@@ -30,6 +30,13 @@ function open_command() {
               ;;
   esac
 
+  # If a URL is passed, $BROWSER might be set to a local browser within SSH.
+  # See https://github.com/ohmyzsh/ohmyzsh/issues/11098
+  if [[ -n "$BROWSER" && "$1" = (http|https)://* ]]; then
+    "$BROWSER" "$@"
+    return
+  fi
+
   ${=open_cmd} "$@" &>/dev/null
 }
 
-- 
cgit v1.2.3-70-g09d2