#!/usr/bin/env bash res=$(dig +timeout=3 +short myip.opendns.com @resolver1.opendns.com 2>/dev/null) if [ -z "$res+x" ]; then text="NO CONN" echo "%{F@error@}${text}%{F-}" exit 0 fi echo "%{F@success@}${res}%{F-}"