<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Colors in GHCi</title>
	<atom:link href="http://martijn.van.steenbergen.nl/journal/2010/02/27/colors-in-ghci/feed/" rel="self" type="application/rss+xml" />
	<link>http://martijn.van.steenbergen.nl/journal/2010/02/27/colors-in-ghci/</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Mon, 13 May 2013 18:02:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
	<item>
		<title>By: Joel</title>
		<link>http://martijn.van.steenbergen.nl/journal/2010/02/27/colors-in-ghci/#comment-343</link>
		<dc:creator>Joel</dc:creator>
		<pubDate>Sat, 10 Sep 2011 21:37:08 +0000</pubDate>
		<guid isPermaLink="false">http://martijn.van.steenbergen.nl/journal/?p=467#comment-343</guid>
		<description>Why not go all out and style the output as well? Here&#039;s what I came up:


#!/bin/sh

# Colors
red=`echo &quot;33[91m&quot;`
green=`echo &quot;33[92m&quot;`
yellow=`echo &quot;33[93m&quot;`
blue=`echo &quot;33[94m&quot;`
purple=`echo &quot;33[95m&quot;`
cyan=`echo &quot;33[96m&quot;`

# Bold colors
bold=`echo &quot;33[1m&quot;`
bold_red=`echo &quot;33[1;91m&quot;`
bold_green=`echo &quot;33[1;92m&quot;`
bold_yellow=`echo &quot;33[1;93m&quot;`
bold_blue=`echo &quot;33[1;94m&quot;`
bold_purple=`echo &quot;33[1;95m&quot;`
bold_cyan=`echo &quot;33[1;96m&quot;`

# Color reset
reset=`echo &quot;33[0m&quot;`

# Patterns
double_colon=&quot;s/::/$red&amp;$reset/;&quot;
rocket=&quot;s/=&gt;/$red&amp;$reset/;&quot;
left_arrow=&quot;s//$red&amp;$reset/;&quot;
strings=&quot;s/&quot;[^&quot;]*&quot;/$yellow&amp;$reset/g;&quot;
chars=&quot;s/&#039;[a-zA-Z]*&#039;/$purple&amp;$reset/g;&quot;

exec &quot;`which ghc`&quot; --interactive ${1+&quot;$@&quot;} &#124;
  sed &quot;$double_colon
       $rocket
       $right_arrow
       $left_arrow
       $strings
       $chars&quot;


You could really take this pretty far and style all sorts of things. Numbers however can get a bit dicey since the color codes contain numbers.

Though this feels a bit hackish, it works well enough for me.</description>
		<content:encoded><![CDATA[<p>Why not go all out and style the output as well? Here&#8217;s what I came up:</p>
<p>#!/bin/sh</p>
<p># Colors<br />
red=`echo &#8220;33[91m"`<br />
green=`echo "33[92m"`<br />
yellow=`echo "33[93m"`<br />
blue=`echo "33[94m"`<br />
purple=`echo "33[95m"`<br />
cyan=`echo "33[96m"`</p>
<p># Bold colors<br />
bold=`echo "33[1m"`<br />
bold_red=`echo "33[1;91m"`<br />
bold_green=`echo "33[1;92m"`<br />
bold_yellow=`echo "33[1;93m"`<br />
bold_blue=`echo "33[1;94m"`<br />
bold_purple=`echo "33[1;95m"`<br />
bold_cyan=`echo "33[1;96m"`</p>
<p># Color reset<br />
reset=`echo "33[0m"`</p>
<p># Patterns<br />
double_colon="s/::/$red&amp;$reset/;"<br />
rocket="s/=&gt;/$red&amp;$reset/;"<br />
left_arrow="s//$red&amp;$reset/;"<br />
strings="s/"[^"]*&#8221;/$yellow&amp;$reset/g;&#8221;<br />
chars=&#8221;s/&#8217;[a-zA-Z]*&#8217;/$purple&amp;$reset/g;&#8221;</p>
<p>exec &#8220;`which ghc`&#8221; &#8211;interactive ${1+&#8221;$@&#8221;} |<br />
  sed &#8220;$double_colon<br />
       $rocket<br />
       $right_arrow<br />
       $left_arrow<br />
       $strings<br />
       $chars&#8221;</p>
<p>You could really take this pretty far and style all sorts of things. Numbers however can get a bit dicey since the color codes contain numbers.</p>
<p>Though this feels a bit hackish, it works well enough for me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yifan Yu</title>
		<link>http://martijn.van.steenbergen.nl/journal/2010/02/27/colors-in-ghci/#comment-342</link>
		<dc:creator>Yifan Yu</dc:creator>
		<pubDate>Tue, 28 Sep 2010 02:53:05 +0000</pubDate>
		<guid isPermaLink="false">http://martijn.van.steenbergen.nl/journal/?p=467#comment-342</guid>
		<description>This works fine. But when I try to edit a file in ghci (`:set editor vim&#039; was performed) by using:

:e Somefile.hs

Vim gives a warning: Output is not to a terminal, and the file could not be edited.

Is there a way to handle this?</description>
		<content:encoded><![CDATA[<p>This works fine. But when I try to edit a file in ghci (`:set editor vim&#8217; was performed) by using:</p>
<p>:e Somefile.hs</p>
<p>Vim gives a warning: Output is not to a terminal, and the file could not be edited.</p>
<p>Is there a way to handle this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: enoksrd</title>
		<link>http://martijn.van.steenbergen.nl/journal/2010/02/27/colors-in-ghci/#comment-341</link>
		<dc:creator>enoksrd</dc:creator>
		<pubDate>Thu, 16 Sep 2010 02:30:44 +0000</pubDate>
		<guid isPermaLink="false">http://martijn.van.steenbergen.nl/journal/?p=467#comment-341</guid>
		<description>Note: the backslash-zero sequences (&#039;s; double backslash here (\\), hope that works ...) disappeared in my and Tom&#039;s comments.</description>
		<content:encoded><![CDATA[<p>Note: the backslash-zero sequences (&#8216;s; double backslash here (\\), hope that works &#8230;) disappeared in my and Tom&#8217;s comments.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: enoksrd</title>
		<link>http://martijn.van.steenbergen.nl/journal/2010/02/27/colors-in-ghci/#comment-340</link>
		<dc:creator>enoksrd</dc:creator>
		<pubDate>Thu, 16 Sep 2010 02:28:08 +0000</pubDate>
		<guid isPermaLink="false">http://martijn.van.steenbergen.nl/journal/?p=467#comment-340</guid>
		<description>Nice hack!  But what I really wanted was to colorize the prompt, so that I could easily tell where long output (e.g. from :browse) started.  I don&#039;t understand why, but the sed trick doesn&#039;t work for the prompt.  But setting an ansi colored prompt in the ghci conf worked:

echo -e :set prompt &#039;&quot;33[32;1m%s33[34;1m&gt;33[0m &quot;&#039; &gt; ~/.ghc/ghci.conf</description>
		<content:encoded><![CDATA[<p>Nice hack!  But what I really wanted was to colorize the prompt, so that I could easily tell where long output (e.g. from :browse) started.  I don&#8217;t understand why, but the sed trick doesn&#8217;t work for the prompt.  But setting an ansi colored prompt in the ghci conf worked:</p>
<p>echo -e :set prompt &#8216;&#8221;33[32;1m%s33[34;1m&gt;33[0m &#8220;&#8216; &gt; ~/.ghc/ghci.conf</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martijn</title>
		<link>http://martijn.van.steenbergen.nl/journal/2010/02/27/colors-in-ghci/#comment-339</link>
		<dc:creator>Martijn</dc:creator>
		<pubDate>Thu, 24 Jun 2010 09:24:03 +0000</pubDate>
		<guid isPermaLink="false">http://martijn.van.steenbergen.nl/journal/?p=467#comment-339</guid>
		<description>@Orphi Yes, I agree. It shouldn&#039;t be too hard.

@Nikolas Good question. I have no good reason for it.</description>
		<content:encoded><![CDATA[<p>@Orphi Yes, I agree. It shouldn&#8217;t be too hard.</p>
<p>@Nikolas Good question. I have no good reason for it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nikolas Mayr</title>
		<link>http://martijn.van.steenbergen.nl/journal/2010/02/27/colors-in-ghci/#comment-338</link>
		<dc:creator>Nikolas Mayr</dc:creator>
		<pubDate>Wed, 03 Mar 2010 13:39:18 +0000</pubDate>
		<guid isPermaLink="false">http://martijn.van.steenbergen.nl/journal/?p=467#comment-338</guid>
		<description>Why are you using

#!/usr/bin/env bash

intead of

#!/bin/bash

?</description>
		<content:encoded><![CDATA[<p>Why are you using</p>
<p>#!/usr/bin/env bash</p>
<p>intead of</p>
<p>#!/bin/bash</p>
<p>?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Orphi</title>
		<link>http://martijn.van.steenbergen.nl/journal/2010/02/27/colors-in-ghci/#comment-337</link>
		<dc:creator>Orphi</dc:creator>
		<pubDate>Mon, 01 Mar 2010 11:59:37 +0000</pubDate>
		<guid isPermaLink="false">http://martijn.van.steenbergen.nl/journal/?p=467#comment-337</guid>
		<description>I still think GHCi should have this built-in. We already have ansi-terminal on Hackage, which does this in a [ahem] *portable* way. (Your examples don&#039;t work on Windows, because it fails to grok ANSI escape sequences.)</description>
		<content:encoded><![CDATA[<p>I still think GHCi should have this built-in. We already have ansi-terminal on Hackage, which does this in a [ahem] *portable* way. (Your examples don&#8217;t work on Windows, because it fails to grok ANSI escape sequences.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erlend</title>
		<link>http://martijn.van.steenbergen.nl/journal/2010/02/27/colors-in-ghci/#comment-336</link>
		<dc:creator>Erlend</dc:creator>
		<pubDate>Sat, 27 Feb 2010 18:12:54 +0000</pubDate>
		<guid isPermaLink="false">http://martijn.van.steenbergen.nl/journal/?p=467#comment-336</guid>
		<description>Cool. Thanks!
Works perfectly on openSuse 11.2. :-)</description>
		<content:encoded><![CDATA[<p>Cool. Thanks!<br />
Works perfectly on openSuse 11.2. <img src='http://martijn.van.steenbergen.nl/journal/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Lokhorst</title>
		<link>http://martijn.van.steenbergen.nl/journal/2010/02/27/colors-in-ghci/#comment-335</link>
		<dc:creator>Tom Lokhorst</dc:creator>
		<pubDate>Sat, 27 Feb 2010 16:26:56 +0000</pubDate>
		<guid isPermaLink="false">http://martijn.van.steenbergen.nl/journal/?p=467#comment-335</guid>
		<description>This is very useful!

I&#039;ve updated the script to also highlight warnings (as I usually launch ghci from vim with -Wall):

    #!/usr/bin/env bash
    
    YELLOW=`echo -e &#039;33[93m&#039;`
    GREEN=`echo -e &#039;33[92m&#039;`
    RED=`echo -e &#039;33[91m&#039;`
    RESET=`echo -e &#039;33[0m&#039;`
    
    /usr/bin/ghci &quot;${@}&quot; 2&gt;&amp;1 &#124;
      sed &quot;s/ Warning:/${YELLOW}&amp;${RESET}/g;s/^Failed, modules loaded:/${RED}&amp;${RESET}/g;s/^Ok, modules loaded:/${GREEN}&amp;${RESET}/g&quot;

I&#039;m not happy with the fact that this merges the stdout and stderr, but I don&#039;t know of a better way to do this.</description>
		<content:encoded><![CDATA[<p>This is very useful!</p>
<p>I&#8217;ve updated the script to also highlight warnings (as I usually launch ghci from vim with -Wall):</p>
<p>    #!/usr/bin/env bash</p>
<p>    YELLOW=`echo -e &#8217;33[93m&#8217;`<br />
    GREEN=`echo -e &#8217;33[92m&#8217;`<br />
    RED=`echo -e &#8217;33[91m&#8217;`<br />
    RESET=`echo -e &#8217;33[0m&#8217;`</p>
<p>    /usr/bin/ghci &#8220;${@}&#8221; 2&gt;&amp;1 |<br />
      sed &#8220;s/ Warning:/${YELLOW}&amp;${RESET}/g;s/^Failed, modules loaded:/${RED}&amp;${RESET}/g;s/^Ok, modules loaded:/${GREEN}&amp;${RESET}/g&#8221;</p>
<p>I&#8217;m not happy with the fact that this merges the stdout and stderr, but I don&#8217;t know of a better way to do this.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
