From a9062fdaed6d71a3ed90dd9208c40edae10c0fb1 Mon Sep 17 00:00:00 2001 From: "Stanislav (Stas) Katkov" Date: Mon, 26 May 2025 00:13:40 +0200 Subject: [PATCH] Adding support for Linux e.g xdg-open --- git-open.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/git-open.sh b/git-open.sh index e380508..7e024b1 100755 --- a/git-open.sh +++ b/git-open.sh @@ -65,8 +65,18 @@ elif [ $# = 2 ]; then repo=$2 fi +# Detect the appropriate open command based on the operating system +if command -v xdg-open >/dev/null 2>&1; then + open_cmd="xdg-open" +elif command -v open >/dev/null 2>&1; then + open_cmd="open" +else + echo "Error: No suitable open command found (tried xdg-open and open)" + exit 1 +fi + if [ -n "${DEBUG:-}" ]; then echo $baseurl/$username/$repo else - open $baseurl/$username/$repo + $open_cmd $baseurl/$username/$repo fi