about summary refs log tree commit diff
path: root/ghcic
diff options
context:
space:
mode:
Diffstat (limited to 'ghcic')
-rwxr-xr-xghcic48
1 files changed, 48 insertions, 0 deletions
diff --git a/ghcic b/ghcic
new file mode 100755
index 0000000..39c75e1
--- /dev/null
+++ b/ghcic
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+
+red="$(echo -e '\033[91m')"
+green="$(echo -e '\033[92m')"
+yellow="$(echo -e '\033[93m')"
+blue="$(echo -e '\033[94m')"
+purple="$(echo -e '\033[95m')"
+cyan="$(echo -e '\033[96m')"
+default="$(echo -e '\033[0m')"
+
+arrow="s/->/${purple}&${default}/g;"
+arrow_double="s/=>/${purple}&${default}/g;"
+bracket_left="s/\[\([^09]\)/${blue}[${default}\1/g;"
+bracket_left_double="s/\[\([^\[0-9]\)/${blue}[${default}\1/g;"
+bracket_right="s/\]/${blue}&${default}/g;"
+bullet="s/•/${yellow}&${default}/g;"
+calc_operators="s/[+\-\/*]/${purple}&${default}/g;"
+char="s/'\\?.'/${cyan}&${default}/g;"
+double_colon="s/::/${purple}&${default}/g;"
+error="s/error:/${red}error${default}:/g;"
+fancy_quotes="s/‘[^’]*’/${cyan}&${default}/g;"
+interactive="s/^<[^>]*>/${yellow}&${default}/g;"
+line_numbers="s/([0-9]*):([0-9]*)/${blue}&${default}/g;"
+load_done="s/done./${green}&${default}/g;"
+load_failed="s/^Failed, modules loaded/${red}&${default}/g;"
+parenthesis="s/[{}()]/${blue}&${default}/g;"
+string="s/\"[^\"]*\"/${yellow}&${default}/g;"
+
+exec "$(command -v ghc)" --interactive ${1+"${@}"} 2>&1 |
+    sed "                       \
+        $arrow                  \
+        $arrow_double           \
+        $bracket_left           \
+        $bracket_left_double    \
+        $bracket_right          \
+        $bullet                 \
+        $calc_operators         \
+        $char                   \
+        $double_colon           \
+        $error                  \
+        $fancy_quotes           \
+        $interactive            \
+        $line_numbers           \
+        $load_done              \
+        $load_failed            \
+        $parenthesis            \
+        $string                 \
+    "

Consider giving Nix/NixOS a try! <3