Check if we’re running in a Terminal – only pretty print the response
- ID
4e137c6- date
2024-10-24 09:06:22+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
dc0d12c- message
# Check if we're running in a Terminal -- only pretty print the response # with colours if so.- changed files
1 file, 8 additions, 1 deletion
Changed files
text/pp_xml.sh (91) → text/pp_xml.sh (158)
diff --git a/text/pp_xml.sh b/text/pp_xml.sh
index 93a3783..8566e71 100755
--- a/text/pp_xml.sh
+++ b/text/pp_xml.sh
@@ -3,4 +3,11 @@
set -o errexit
set -o nounset
-xmllint --format - | pygmentize -l xml
+if [ -t 1 ]
+then
+ echo "terminal"
+ xmllint --format - | pygmentize -l xml
+else
+ xmllint --format -
+fi
+