Set terminal title in readwwwlog

This commit is contained in:
tastytea 2022-04-15 06:09:36 +02:00
parent bb8fe8f958
commit 8b8010882b
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM

View File

@ -15,17 +15,22 @@ fi
local -a urls=(${@})
local default_cmd="firefox"
local termopts=""
for url in ${urls}; do
if [[ ${url} =~ 'dpaste\.com' && ! ${url[-4,-1]} == ".txt" ]]; then
url+=".txt"
fi
if [[ ${TERMINAL} =~ "alacritty|xfce4-terminal" ]]; then
termopts="--title=${url}"
fi
if curl --silent --location --head ${url} | grep -q 'text/plain'; then
sleep 1 # dpaste.com workaround
local file="$(mktemp --suffix='.readwwwlog')"
curl --silent --location --output ${file} ${url}
${TERMINAL} -e less --LINE-NUMBERS --pattern='(error|fail):' ${file}
${TERMINAL} ${termopts} -e less --LINE-NUMBERS --pattern='(error|fail):' ${file}
rm ${file}
else
${default_cmd} ${url}