From 40be8b703a8bf70121147ea4cfbf08dfae2ddd34 Mon Sep 17 00:00:00 2001 From: Jannis Baum Date: Fri, 4 Aug 2023 14:49:06 +0200 Subject: [PATCH] fix(#14): portable open command --- viv | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/viv b/viv index 516ce115..4f518cb9 100755 --- a/viv +++ b/viv @@ -16,6 +16,16 @@ if ! [ -f "$1" ]; then fi FILE=`realpath "$1"` +if [ -z "$VIV_OPEN" ]; then + which open 1>/dev/null 2>/dev/null && VIV_OPEN="open" + which xdg-open 1>/dev/null 2>/dev/null && VIV_OPEN="xdg-open" + + if [ -z "$VIV_OPEN" ]; then + echo 'Please specify an "open" command in $VIV_OPEN' + exit 1 + fi +fi + [ -z "$VIV_PORT" ] && VIV_PORT=31622 VIV_ADDR=http://localhost:$VIV_PORT [ -z "$VIV_CMD" ] && VIV_CMD=vivify-server @@ -28,4 +38,4 @@ if ! curl --fail-with-body -v $VIV_ADDR/health 1>/dev/null 2>/dev/null; then done fi -open $VIV_ADDR/viewer$FILE +$VIV_OPEN $VIV_ADDR/viewer$FILE