diff options
author | Patrick Spek <p.spek@tyil.nl> | 2019-10-02 16:41:02 +0200 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2019-10-02 16:41:02 +0200 |
commit | 035bb70ce47ce7e5a643b80e130985b6d711e99f (patch) | |
tree | 496b9f03a2e9986b6e1fc25311490c90e0042ae4 /.local/bin/uncolor | |
parent | d62f1d1673fc0a319ea4581dee0f6085b1f70005 (diff) |
Add a number of shell utilities
Diffstat (limited to '.local/bin/uncolor')
-rwxr-xr-x | .local/bin/uncolor | 20 |
1 files changed, 20 insertions, 0 deletions
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 "$@" |