<?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"
	>
<channel>
	<title>Comments on: 借我一双写轮眼──Less 语法高亮</title>
	<atom:link href="http://linuxtoy.org/archives/less-highlight.html/feed" rel="self" type="application/rss+xml" />
	<link>http://linuxtoy.org/archives/less-highlight.html</link>
	<description>LinuxTOY 是一个致力于提供 Linux 相关资讯的专题站点。如果您发现了好用好玩的 Linux 东东并愿意发扬自由、分享的精神，可以点击顶部导航 Contact 按钮进行投稿。</description>
	<pubDate>Mon, 22 Mar 2010 04:37:09 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: windwiny</title>
		<link>http://linuxtoy.org/archives/less-highlight.html#comment-100641</link>
		<dc:creator>windwiny</dc:creator>
		<pubDate>Fri, 09 Jan 2009 05:45:39 +0000</pubDate>
		<guid isPermaLink="false">http://linuxtoy.org/?p=2713#comment-100641</guid>
		<description>&lt;p&gt;不是可以用这个？
export LESS&lt;em&gt;TERMCAP&lt;/em&gt;mb=$'33[01;31m'
export LESS&lt;em&gt;TERMCAP&lt;/em&gt;md=$'33[01;31m'
export LESS&lt;em&gt;TERMCAP&lt;/em&gt;me=$'33[0m'
export LESS&lt;em&gt;TERMCAP&lt;/em&gt;se=$'33[0m'
export LESS&lt;em&gt;TERMCAP&lt;/em&gt;so=$'33[01;44m'
export LESS&lt;em&gt;TERMCAP&lt;/em&gt;ue=$'33[0m'
export LESS&lt;em&gt;TERMCAP&lt;/em&gt;us=$'33[01;32m'&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>不是可以用这个？
export LESS<em>TERMCAP</em>mb=$'33[01;31m'
export LESS<em>TERMCAP</em>md=$'33[01;31m'
export LESS<em>TERMCAP</em>me=$'33[0m'
export LESS<em>TERMCAP</em>se=$'33[0m'
export LESS<em>TERMCAP</em>so=$'33[01;44m'
export LESS<em>TERMCAP</em>ue=$'33[0m'
export LESS<em>TERMCAP</em>us=$'33[01;32m'</p>]]></content:encoded>
	</item>
	<item>
		<title>By: somebody(莫多)</title>
		<link>http://linuxtoy.org/archives/less-highlight.html#comment-100601</link>
		<dc:creator>somebody(莫多)</dc:creator>
		<pubDate>Thu, 08 Jan 2009 15:37:24 +0000</pubDate>
		<guid isPermaLink="false">http://linuxtoy.org/?p=2713#comment-100601</guid>
		<description>&lt;p&gt;我也把PAGER换成most了.这样man的时候也高亮了.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>我也把PAGER换成most了.这样man的时候也高亮了.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: dybnu</title>
		<link>http://linuxtoy.org/archives/less-highlight.html#comment-100576</link>
		<dc:creator>dybnu</dc:creator>
		<pubDate>Thu, 08 Jan 2009 11:28:59 +0000</pubDate>
		<guid isPermaLink="false">http://linuxtoy.org/?p=2713#comment-100576</guid>
		<description>&lt;p&gt;@&lt;a href="#comment-100560" rel="nofollow"&gt;more&lt;/a&gt;: 这主意好，哈&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@<a href="#comment-100560" rel="nofollow">more</a>: 这主意好，哈</p>]]></content:encoded>
	</item>
	<item>
		<title>By: RRG</title>
		<link>http://linuxtoy.org/archives/less-highlight.html#comment-100565</link>
		<dc:creator>RRG</dc:creator>
		<pubDate>Thu, 08 Jan 2009 09:51:24 +0000</pubDate>
		<guid isPermaLink="false">http://linuxtoy.org/?p=2713#comment-100565</guid>
		<description>&lt;p&gt;用了/usr/share/source-highlight/src-hilite-lesspipe.sh还是不行？
还是用vim/view当less使好了&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>用了/usr/share/source-highlight/src-hilite-lesspipe.sh还是不行？
还是用vim/view当less使好了</p>]]></content:encoded>
	</item>
	<item>
		<title>By: more</title>
		<link>http://linuxtoy.org/archives/less-highlight.html#comment-100560</link>
		<dc:creator>more</dc:creator>
		<pubDate>Thu, 08 Jan 2009 09:03:10 +0000</pubDate>
		<guid isPermaLink="false">http://linuxtoy.org/?p=2713#comment-100560</guid>
		<description>&lt;p&gt;想高亮在less中直接按v就近到vim了&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>想高亮在less中直接按v就近到vim了</p>]]></content:encoded>
	</item>
	<item>
		<title>By: dybnu</title>
		<link>http://linuxtoy.org/archives/less-highlight.html#comment-100557</link>
		<dc:creator>dybnu</dc:creator>
		<pubDate>Thu, 08 Jan 2009 08:40:36 +0000</pubDate>
		<guid isPermaLink="false">http://linuxtoy.org/?p=2713#comment-100557</guid>
		<description>&lt;p&gt;@&lt;a href="#comment-100542" rel="nofollow"&gt;Kardinal&lt;/a&gt;: 我修改了这个才有效的，呵呵 /usr/share/source-highlight/default.lang&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@<a href="#comment-100542" rel="nofollow">Kardinal</a>: 我修改了这个才有效的，呵呵 /usr/share/source-highlight/default.lang</p>]]></content:encoded>
	</item>
	<item>
		<title>By: kwyd</title>
		<link>http://linuxtoy.org/archives/less-highlight.html#comment-100543</link>
		<dc:creator>kwyd</dc:creator>
		<pubDate>Thu, 08 Jan 2009 06:56:50 +0000</pubDate>
		<guid isPermaLink="false">http://linuxtoy.org/?p=2713#comment-100543</guid>
		<description>&lt;p&gt;晕，修正一下上面说的， 其他 Kardinal 加到 .bashrc的都可以删，但是这条
export LESS="-R"
还是要继续放在 .bashrc 中的，否则会出问题。&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>晕，修正一下上面说的， 其他 Kardinal 加到 .bashrc的都可以删，但是这条
export LESS="-R"
还是要继续放在 .bashrc 中的，否则会出问题。</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Kardinal</title>
		<link>http://linuxtoy.org/archives/less-highlight.html#comment-100542</link>
		<dc:creator>Kardinal</dc:creator>
		<pubDate>Thu, 08 Jan 2009 06:56:41 +0000</pubDate>
		<guid isPermaLink="false">http://linuxtoy.org/?p=2713#comment-100542</guid>
		<description>&lt;p&gt;@dybnu:不同系统下路径可能不一样
@hmy: most 早就用过，虽然是彩色的，但不能说是”语法高亮“吧 ^&lt;em&gt;^
@walkerxk:是滴
@web81：本来里面有一句”不同系统下路径可能不一样“，但是我编辑了一次，出了点错，帖子的下半身让 wp 给吃了……惨不忍睹……
@ kwyd： less 还能查看压缩包呢？ ^&lt;/em&gt;^&#124;&#124; 俺试试&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@dybnu:不同系统下路径可能不一样
@hmy: most 早就用过，虽然是彩色的，但不能说是”语法高亮“吧 ^<em>^
@walkerxk:是滴
@web81：本来里面有一句”不同系统下路径可能不一样“，但是我编辑了一次，出了点错，帖子的下半身让 wp 给吃了……惨不忍睹……
@ kwyd： less 还能查看压缩包呢？ ^</em>^|| 俺试试</p>]]></content:encoded>
	</item>
	<item>
		<title>By: kwyd</title>
		<link>http://linuxtoy.org/archives/less-highlight.html#comment-100540</link>
		<dc:creator>kwyd</dc:creator>
		<pubDate>Thu, 08 Jan 2009 06:53:17 +0000</pubDate>
		<guid isPermaLink="false">http://linuxtoy.org/?p=2713#comment-100540</guid>
		<description>&lt;p&gt;改进了一下 Kardinal 的方法， Kardinal的方法的缺陷在于把默认的 lesspipe 浏览一些binary文件 （如.gz,等）的功能给抹掉了。&lt;/p&gt;

&lt;p&gt;在ubuntu中 (我用的是 8.04/8.10)，默认在 ~/.bashrc 是调用了 lesspipe来设置 LESSOPEN 为 "&#124; /usr/bin/lesspipe %s" 的， 如果直接使用  Kardinal 的方法， 虽然能语法高亮文本文件了，但是却无法用less看压缩包内容。 用less看压缩包等二进制文件的具体信息可以 man lesspipe.&lt;/p&gt;

&lt;p&gt;解决方法为，使用 lesspipe的 filter 功能， 以把下述内容保存为 ~/.lessfilter ， 并且 chmod +x ~/.lessfilter，同时把Kardinal文中加入到 .bashrc的所有内容都删除，确认你的 .bashrc中调用了 lesspipe (ubuntu 默认启动），然后重开一下terminal， 就可以发现配置文件/源代码可以高亮显示，并且还能正确打开.tar.gz等文件了。&lt;/p&gt;

&lt;h1&gt;!/bin/bash&lt;/h1&gt;

&lt;p&gt;case $1 in
    &lt;em&gt;ChangeLog&#124;&lt;/em&gt;changelog) 
    /usr/bin/source-highlight --failsafe -f esc --lang-def=changelog.lang --style-file=esc.style -i $1 ;;
    &lt;em&gt;Makefile&#124;&lt;/em&gt;makefile) 
    /usr/bin/source-highlight --failsafe -f esc --lang-def=makefile.lang --style-file=esc.style -i $1 ;;
    &lt;em&gt;profile&#124;&lt;/em&gt;bashrc)
    /usr/bin/source-highlight --failsafe -f esc --lang-def=sh.lang --style-file=esc.style -i $1 ;;
    *)
    /usr/bin/source-highlight --infer-lang -f esc --style-file=esc.style -i $1 2&#62;/dev/null &#124;&#124; exit 1 ;;
esac&lt;/p&gt;

&lt;p&gt;exit 0&lt;/p&gt;

&lt;p&gt;ps, 上面这个 .lessfilter文件是基于 /usr/share/source-highlight/src-hilite-lesspipe.sh 做了少许改动而成。&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>改进了一下 Kardinal 的方法， Kardinal的方法的缺陷在于把默认的 lesspipe 浏览一些binary文件 （如.gz,等）的功能给抹掉了。</p>

<p>在ubuntu中 (我用的是 8.04/8.10)，默认在 ~/.bashrc 是调用了 lesspipe来设置 LESSOPEN 为 "| /usr/bin/lesspipe %s" 的， 如果直接使用  Kardinal 的方法， 虽然能语法高亮文本文件了，但是却无法用less看压缩包内容。 用less看压缩包等二进制文件的具体信息可以 man lesspipe.</p>

<p>解决方法为，使用 lesspipe的 filter 功能， 以把下述内容保存为 ~/.lessfilter ， 并且 chmod +x ~/.lessfilter，同时把Kardinal文中加入到 .bashrc的所有内容都删除，确认你的 .bashrc中调用了 lesspipe (ubuntu 默认启动），然后重开一下terminal， 就可以发现配置文件/源代码可以高亮显示，并且还能正确打开.tar.gz等文件了。</p>

<h1>!/bin/bash</h1>

<p>case $1 in
    <em>ChangeLog|</em>changelog) 
    /usr/bin/source-highlight --failsafe -f esc --lang-def=changelog.lang --style-file=esc.style -i $1 ;;
    <em>Makefile|</em>makefile) 
    /usr/bin/source-highlight --failsafe -f esc --lang-def=makefile.lang --style-file=esc.style -i $1 ;;
    <em>profile|</em>bashrc)
    /usr/bin/source-highlight --failsafe -f esc --lang-def=sh.lang --style-file=esc.style -i $1 ;;
    *)
    /usr/bin/source-highlight --infer-lang -f esc --style-file=esc.style -i $1 2&gt;/dev/null || exit 1 ;;
esac</p>

<p>exit 0</p>

<p>ps, 上面这个 .lessfilter文件是基于 /usr/share/source-highlight/src-hilite-lesspipe.sh 做了少许改动而成。</p>]]></content:encoded>
	</item>
	<item>
		<title>By: web81</title>
		<link>http://linuxtoy.org/archives/less-highlight.html#comment-100538</link>
		<dc:creator>web81</dc:creator>
		<pubDate>Thu, 08 Jan 2009 06:18:00 +0000</pubDate>
		<guid isPermaLink="false">http://linuxtoy.org/?p=2713#comment-100538</guid>
		<description>&lt;p&gt;貌似8.04里面这个文件位置不一样
/usr/share/source-highlight/src-hilite-lesspipe.sh&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>貌似8.04里面这个文件位置不一样
/usr/share/source-highlight/src-hilite-lesspipe.sh</p>]]></content:encoded>
	</item>
</channel>
</rss>
