From 837077ea3965272b1a2ef2b42b201fd83f57d477 Mon Sep 17 00:00:00 2001 From: tastytea Date: Fri, 15 Apr 2022 14:48:54 +0200 Subject: [PATCH] readwwwlog: Don't open terminal if already in terminal --- .config/zsh/functions/readwwwlog | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.config/zsh/functions/readwwwlog b/.config/zsh/functions/readwwwlog index 28624c4..adde3a6 100755 --- a/.config/zsh/functions/readwwwlog +++ b/.config/zsh/functions/readwwwlog @@ -30,8 +30,13 @@ for url in ${urls}; do sleep 1 # dpaste.com workaround local file="$(mktemp --suffix='.readwwwlog')" curl --silent --location --output ${file} ${url} - ${TERMINAL} ${termopts} -e \ - less --LINE-NUMBERS --pattern='(error|fail):' ${file} + + local -a cmd=(less --LINE-NUMBERS --pattern='(error|fail):' ${file}) + if [[ -o NO_INTERACTIVE ]]; then + cmd=(${TERMINAL} ${termopts} -e ${cmd}) + fi + ${cmd} + rm ${file} else ${default_cmd} ${url}