From 035bb70ce47ce7e5a643b80e130985b6d711e99f Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Wed, 2 Oct 2019 16:41:02 +0200 Subject: Add a number of shell utilities --- .local/bin/uncolor | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 .local/bin/uncolor (limited to '.local/bin/uncolor') diff --git a/.local/bin/uncolor b/.local/bin/uncolor new file mode 100755 index 0000000..68868b2 --- /dev/null +++ b/.local/bin/uncolor @@ -0,0 +1,20 @@ +#! /usr/bin/env sh + +readonly EXPRESSION='s/\x1b\[[0-9;]*m//g' + +main() +{ + if [ "${1:--}" = "-" ] + then + while read line + do + printf "%s\n" "$line" | sed "$EXPRESSION" + done < /dev/stdin + + return 0 + fi + + sed "$EXPRESSION" "$1" +} + +main "$@" -- cgit v1.1