<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>林光生活兩光過 &#187; 工具</title>
	<atom:link href="http://blog.yzlin.org/category/%e9%9b%bb%e8%85%a6%e6%8a%80%e8%a1%93/%e5%b7%a5%e5%85%b7/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.yzlin.org</link>
	<description>人生就該悠閒地過，忠實地記錄下人生的軌跡</description>
	<lastBuildDate>Thu, 21 Jan 2010 15:46:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=3.0-alpha</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Git &#8211; How to edit incorrect commit messages?</title>
		<link>http://blog.yzlin.org/2010/01/21/96/</link>
		<comments>http://blog.yzlin.org/2010/01/21/96/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 15:44:36 +0000</pubDate>
		<dc:creator>yzlin</dc:creator>
				<category><![CDATA[工具]]></category>
		<category><![CDATA[電腦技術]]></category>
		<category><![CDATA[Git]]></category>

		<guid isPermaLink="false">http://blog.yzlin.org/?p=96</guid>
		<description><![CDATA[一般來說，要修改最近一次的 commit，常見的方式有：

git revert &#38; git commit：這個方式很直覺，直接 revert 回上一個版本，然後重新 commit，不過因為 revert 會連這次 commit 中的記錄也消掉，這樣太麻煩了，我只是想改個 commit message 而已啊！XD
git commit &#8211;amend：這個可以直接翻譯成&#8221;重新修改最近這次 commit&#8221;，其相當於
$ git reset &#8211;soft HEAD^
$ &#8230; do something else to come up with the right tree &#8230;
$ git commit -c ORIG_HEAD


然而，對於要修改較舊的 commit，上面的做法可能就不適用了，據我所知目前的做法有兩種，第一種是使用 git rebase：
git rebase &#8211;interactive &#60;after-this-commit-id&#62;

這樣會跳出介面讓你選擇想要修改的 commit，選擇完畢後，會由舊到新依序停在每個你所選擇的 commit，然後利用
git commit &#8211;amend
來修改該次的 commit，再搭配
git rebase &#8211;continue
來繼續下一個選擇的 commit。這種做法很方便，也可以快速地達到目的，因為是用 rebase，修改 commit [...]]]></description>
			<content:encoded><![CDATA[<p>一般來說，要修改最近一次的 commit，常見的方式有：</p>
<ul>
<li>git revert &amp; git commit：這個方式很直覺，直接 revert 回上一個版本，然後重新 commit，不過因為 revert 會連這次 commit 中的記錄也消掉，這樣太麻煩了，我只是想改個 commit message 而已啊！XD</li>
<li>git commit &#8211;amend：這個可以直接翻譯成&#8221;重新修改最近這次 commit&#8221;，其相當於<br />
<blockquote><p>$ git reset &#8211;soft HEAD^<br />
$ &#8230; do something else to come up with the right tree &#8230;<br />
$ git commit -c ORIG_HEAD</p></blockquote>
</li>
</ul>
<p>然而，對於要修改較舊的 commit，上面的做法可能就不適用了，據我所知目前的做法有兩種，第一種是使用 git rebase：</p>
<blockquote><p>git rebase &#8211;interactive &lt;after-this-commit-id&gt;
</p></blockquote>
<p>這樣會跳出介面讓你選擇想要修改的 commit，選擇完畢後，會由舊到新依序停在每個你所選擇的 commit，然後利用</p>
<blockquote><p>git commit &#8211;amend</p></blockquote>
<p>來修改該次的 commit，再搭配</p>
<blockquote><p>git rebase &#8211;continue</p></blockquote>
<p>來繼續下一個選擇的 commit。這種做法很方便，也可以快速地達到目的，因為是用 rebase，修改 commit message 倒是還好，如果有修改到 content，可能就要注意一下 conflict &amp; merge 的問題了。另外，這個方式對某個我試的結果，對於修改 first commit 會沒輒。這時候可能要使用另一種比較麻煩的做法了。</p>
<p>第二種做法是利用一個由要修改的 commit 產生一個 target commit (在另一個 branch 中)，同樣搭配 git commit &#8211;amend 來修改，最後利用 git rebase 來覆蓋原本的 commit：</p>
<blockquote><p># tag the source commit so we can reference it<br />
git tag source-commit &lt;source-commit-id&gt;<br />
# checkout on its own branch<br />
git checkout -b fake-branch source-commit<br />
# amend the commit<br />
git commit &#8211;amend<br />
# after you changed the commit message, checkout the original branch<br />
git checkout &lt;original-branch&gt;<br />
# and rebase it onto the source commit<br />
git rebase &#8211;onto fake-branch source-commit<br />
# then nuke the temporary branch and tag we created<br />
git branch -d fake-branch<br />
git tag -d source-commit</p></blockquote>
<p>就看情形使用了，大部份還是用第一種做法，不過一開始就把 commit message 寫好最省事 XD</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yzlin.org/2010/01/21/96/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fix VMware vSphere Client on Windows 7</title>
		<link>http://blog.yzlin.org/2009/11/05/90/</link>
		<comments>http://blog.yzlin.org/2009/11/05/90/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 03:29:31 +0000</pubDate>
		<dc:creator>yzlin</dc:creator>
				<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[工具]]></category>
		<category><![CDATA[電腦技術]]></category>

		<guid isPermaLink="false">http://blog.yzlin.org/?p=90</guid>
		<description><![CDATA[I&#8217;ve started to use Windows 7 as working desktop OS. When I try to use vSphere Client to connect to ESX Server, it just gives me errors like
Error parsing the server “&#60;server name&#62;” “clients.xml” file.
and
The type initializer for ‘VirtualInfrastructure.Utils.HttpWebRequestProxy’ threw an exception.
After googling, I get some solution. With a little modification from Pank&#8217;s patch, it [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started to use Windows 7 as working desktop OS. When I try to use vSphere Client to connect to ESX Server, it just gives me errors like</p>
<blockquote><p>Error parsing the server “&lt;server name&gt;” “clients.xml” file.</p></blockquote>
<p>and</p>
<blockquote><p>The type initializer for ‘VirtualInfrastructure.Utils.HttpWebRequestProxy’ threw an exception.</p></blockquote>
<p>After googling, I get some <a href="http://www.techhead.co.uk/running-vmware-vsphere-client-on-windows-7" target="_blank">solution</a>. With a little <a href="http://file.yzlin.org/vsphere_client_win7_fix.zip">modification</a> from <a href="http://pank.org/blog/2009/10/vmware-vsphere-fix-w7.html" target="_blank">Pank&#8217;s patch</a>, it works fine now. <img src='http://blog.yzlin.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>P.S. The newer version 2.0.50727.4927 of system.dll seems not work, so that&#8217;s why to pack version 2.0.50727.3053.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yzlin.org/2009/11/05/90/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VIM: Hack Your Editor!!</title>
		<link>http://blog.yzlin.org/2009/03/09/80/</link>
		<comments>http://blog.yzlin.org/2009/03/09/80/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 13:20:55 +0000</pubDate>
		<dc:creator>yzlin</dc:creator>
				<category><![CDATA[NCTUCS]]></category>
		<category><![CDATA[工作記錄]]></category>
		<category><![CDATA[工具]]></category>
		<category><![CDATA[電腦技術]]></category>

		<guid isPermaLink="false">http://blog.yzlin.org/?p=80</guid>
		<description><![CDATA[在系計中的小分享，這次著重在開發環境和 Plugin，蠻多部份沒有在 Slides 點出來，而是用口頭講述的，也有很多東西來不及準備完所以就沒講了，不過這種東西還是實際去玩學得比較快，也比較容易了解原理。:P
]]></description>
			<content:encoded><![CDATA[<p>在系計中的<a href="http://file.yzlin.org/VIM_Hack_Your_Editor.pdf">小分享</a>，這次著重在開發環境和 Plugin，蠻多部份沒有在 Slides 點出來，而是用口頭講述的，也有很多東西來不及準備完所以就沒講了，不過這種東西還是實際去玩學得比較快，也比較容易了解原理。:P</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yzlin.org/2009/03/09/80/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Tab Completion on Python Shell</title>
		<link>http://blog.yzlin.org/2008/12/22/75/</link>
		<comments>http://blog.yzlin.org/2008/12/22/75/#comments</comments>
		<pubDate>Sun, 21 Dec 2008 17:21:40 +0000</pubDate>
		<dc:creator>yzlin</dc:creator>
				<category><![CDATA[工具]]></category>
		<category><![CDATA[電腦技術]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.yzlin.org/?p=75</guid>
		<description><![CDATA[Python 本身的 Interactive Mode (Shell) 其實對於測試一些小功能和 debug，都蠻有用的，不過它的功能一直讓我覺得很陽春，尤其是 Tab Completion，我一直以為沒有實作這個功能，後來在 &#8220;Python for Unix and Linux System Administration&#8221; 這本書看到原來可以手動打開這個功能：

&#62;&#62;&#62; import rlcompleter, readline
&#62;&#62;&#62; readline.parse_and_bind('tab: complete')

這樣便可以使用 Tab Completion 的功能了，結果大致上會是：

&#62;&#62;&#62; import os
&#62;&#62;&#62; os.lis&#60;TAB&#62;
&#62;&#62;&#62; os.listdir
&#62;&#62;&#62; os.li&#60;TAB&#62;&#60;TAB&#62;
os.linesep  os.link    os.listdir

雖然有了基本的 Tab Completion 功能，但說真的，還是挺不習慣 Python 原本的 Shell，後來都改用 IPython 了，比原本的 Python Shell 強大很多，重點是&#8230;它會自動 Indent，我不用再按&#60;TAB&#62;按到死了。
]]></description>
			<content:encoded><![CDATA[<p>Python 本身的 Interactive Mode (Shell) 其實對於測試一些小功能和 debug，都蠻有用的，不過它的功能一直讓我覺得很陽春，尤其是 Tab Completion，我一直以為沒有實作這個功能，後來在 &#8220;Python for Unix and Linux System Administration&#8221; 這本書看到原來可以手動打開這個功能：</p>
<blockquote>
<pre>&gt;&gt;&gt; import rlcompleter, readline
&gt;&gt;&gt; readline.parse_and_bind('tab: complete')</pre>
</blockquote>
<p>這樣便可以使用 Tab Completion 的功能了，結果大致上會是：</p>
<blockquote>
<pre>&gt;&gt;&gt; import os
&gt;&gt;&gt; os.lis&lt;TAB&gt;
&gt;&gt;&gt; os.listdir
&gt;&gt;&gt; os.li&lt;TAB&gt;&lt;TAB&gt;
os.linesep  os.link    os.listdir</pre>
</blockquote>
<p>雖然有了基本的 Tab Completion 功能，但說真的，還是挺不習慣 Python 原本的 Shell，後來都改用 <a href="http://ipython.scipy.org" target="_blank">IPython</a> 了，比原本的 Python Shell 強大很多，重點是&#8230;它會自動 Indent，我不用再按&lt;TAB&gt;按到死了。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yzlin.org/2008/12/22/75/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Firefox + VIM = vimperator</title>
		<link>http://blog.yzlin.org/2008/12/18/73/</link>
		<comments>http://blog.yzlin.org/2008/12/18/73/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 11:17:18 +0000</pubDate>
		<dc:creator>yzlin</dc:creator>
				<category><![CDATA[工具]]></category>
		<category><![CDATA[電腦技術]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://blog.yzlin.org/?p=73</guid>
		<description><![CDATA[最近看到一個 Firefox Extension &#8220;vimperator&#8220;，我只能說，這個東西真是太棒了，尤其對我這種 VIM 重度使用者來說，真是一大福音啊！
看了一下官網的說明，大部份的常用指令都有實作，而且一裝完介面瞬間感受得到有種 VIM-Style，官網還有 Tips &#38; Tricks 專區，不過目前看來數量沒有很多，google 一下應該可以找到更多人的使用經驗，也有些人直接把設定放出來。
現在正在探索它的設定，畢竟跟原本的 VIM 還是有些許不同，對於網頁瀏覽方面應該會有一些對應的設定和功能以增加方便性。有心得再 post 出來。
]]></description>
			<content:encoded><![CDATA[<p>最近看到一個 Firefox Extension &#8220;<a href="http://vimperator.org/trac/wiki/Vimperator" target="_blank">vimperator</a>&#8220;，我只能說，這個東西真是太棒了，尤其對我這種 VIM 重度使用者來說，真是一大福音啊！</p>
<p>看了一下官網的說明，大部份的常用指令都有實作，而且一裝完介面瞬間感受得到有種 VIM-Style，官網還有 <a href="http://vimperator.org/trac/wiki/Vimperator/Tips&amp;Tricks" target="_blank">Tips &amp; Tricks</a> 專區，不過目前看來數量沒有很多，google 一下應該可以找到更多人的使用經驗，也<a href="http://developernotes.com/post/Vim-2b-Firefox-3d-Vimperator.aspx" target="_blank">有些人</a>直接把設定放出來。</p>
<p>現在正在探索它的設定，畢竟跟原本的 VIM 還是有些許不同，對於網頁瀏覽方面應該會有一些對應的設定和功能以增加方便性。有心得再 post 出來。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yzlin.org/2008/12/18/73/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Screen + Unicode 補完計畫 (UAO)</title>
		<link>http://blog.yzlin.org/2008/11/11/66/</link>
		<comments>http://blog.yzlin.org/2008/11/11/66/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 00:14:06 +0000</pubDate>
		<dc:creator>yzlin</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[工具]]></category>
		<category><![CDATA[電腦技術]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[screen]]></category>

		<guid isPermaLink="false">http://blog.yzlin.org/?p=66</guid>
		<description><![CDATA[這篇其實很早就有草稿了，只是拖到最近才把它完成。
之前有談過如何設定 Gnu Screen 的方法，如果你常掛在 server 上，那應該對 Screen 這個好用的工具並不陌生。這篇主要是談怎麼 patch 它，來讓它支援 Unicode 補完計畫 (UAO)。
Unicode 補完計畫 (UAO) 對廣大的鄉民來說，可以說是再親切不過的了，BBS 電子佈告欄在台灣相當地盛行，但它底層僅僅支援 Big5，對於鄉民來說，看日文是件再正常不過的事了，但 Big5 畢竟是個急就章推出的編碼 (事實上，它也沒有一個既定的標準，唯一勉強可以稱得上標準的是 Big5-2003)，在當初的設計中並沒有加入日文假名等使用需求。所幸 Big5 有所謂的&#8221;使用者造字區&#8221;，提供給使用者自行定義新字，也有了後來的&#8221;倚天擴充字集&#8221;加入了包括日文假名等使用者特殊需求字。
然而，Windows 對於這塊由倚天自行定義的區域，在轉換成 Unicode 時也對應到了使用者造字區，而非它們各自對應到實際在 Unicode 的字，於是造成了 mapping 上的錯誤。UAO 便是為了解決這個問題而產生的，它做的事情只是將這段使用者造字區對應到 Unicode 正確的字。
上面說到的，是針對 Big5 &#60;-&#62; Unicode 的轉換發生在 Windows 的情況，可以利用安裝 UAO 來解決；但因為我的環境是 UTF-8，已經習慣用 Screen 提供的 Encoding Translation 功能來上 BBS 瀏覽文章了，但 Screen 預設提供的 Mapping Table 並沒有處理 [...]]]></description>
			<content:encoded><![CDATA[<p>這篇其實很早就有草稿了，只是拖到最近才把它完成。</p>
<p>之前有談過如何設定 Gnu Screen 的方法，如果你常掛在 server 上，那應該對 Screen 這個好用的工具並不陌生。這篇主要是談怎麼 patch 它，來讓它支援 Unicode 補完計畫 (UAO)。</p>
<p>Unicode 補完計畫 (UAO) 對廣大的鄉民來說，可以說是再親切不過的了，BBS 電子佈告欄在台灣相當地盛行，但它底層僅僅支援 Big5，對於鄉民來說，看日文是件再正常不過的事了，但 Big5 畢竟是個急就章推出的編碼 (事實上，它也沒有一個既定的標準，唯一勉強可以稱得上標準的是 Big5-2003)，在當初的設計中並沒有加入日文假名等使用需求。所幸 Big5 有所謂的&#8221;使用者造字區&#8221;，提供給使用者自行定義新字，也有了後來的&#8221;倚天擴充字集&#8221;加入了包括日文假名等使用者特殊需求字。</p>
<p>然而，Windows 對於這塊由倚天自行定義的區域，在轉換成 Unicode 時也對應到了使用者造字區，而非它們各自對應到實際在 Unicode 的字，於是造成了 mapping 上的錯誤。UAO 便是為了解決這個問題而產生的，它做的事情只是將這段使用者造字區對應到 Unicode 正確的字。</p>
<p>上面說到的，是針對 Big5 &lt;-&gt; Unicode 的轉換發生在 Windows 的情況，可以利用安裝 UAO 來解決；但因為我的環境是 UTF-8，已經習慣用 Screen 提供的 Encoding Translation 功能來上 BBS 瀏覽文章了，但 Screen 預設提供的 Mapping Table 並沒有處理 UAO，因此這種轉換是在 Screen 內部的情況便無法靠安裝 UAO 來解決，所以必須 patch。</p>
<p>其實許多前輩們已經針對這個部份提供了 Screen 的 <a href="http://tib.tw/tBoard/index.py?m=pl&amp;f=25&amp;t=564">UAO patch</a> 以及修正過的 Mapping Table，但他們提供的 Mapping Table 是以 UAO 2.42 所產生的 Binary 檔，這意味著我不清楚它是支援到 UAO 2.42 哪個程度，即使完整支援了 (這反而不好)，Binary 檔也代表它難以再編修和進 Version Control System。</p>
<p>所以我從 Firefox 3 的版本取出了內建的 Mapping Table 文字檔來做處理，Firefox 在 2 的版本已經內建單向處理 UAO 的功能了，所以可以取其 Big5 -&gt; Unicode 單向的 Mapping Table 來做修改。修改後再利用<a href="http://www.csie.ntu.edu.tw/~r92030/project/big5/">轉換程式</a>編成 Binary 檔便可替代原本 Screen 當中的 &#8220;18&#8243; 檔 (也就是 Big5 &lt;-&gt; Unicode Mapping Table)。</p>
<p>利用修正過後的 Screen 便可看到在日文假名以及某些特殊字框的顯示正常很多了；但是實際使用後會發現一個問題，就是對於某些 Double Mapping 的字會優先轉換到 0&#215;8140-0xA0FE 這段擴充區 (這裡所謂的 Double Mapping 是指多個 Big5 的字對應到同一個 Unicode 的字，例如 0xB86D 和 0&#215;82AA 都是對應到 0&#215;7F6E，一個是正常區的，另一個是擴充區的)，而在當初的 Mapping Table 文字檔便是依造 Big5 的字碼來排序，很不巧的 0&#215;8140-0xA0FE 這段擴充區會放置在最前面；而又剛好 Screen 的 Mapping Table 是同時做雙向轉換的，針對這種 Double Mapping 的情況，它會以第一個找到的為優先，這便造成了某些不需 UAO 便可閱讀的字，變成需要 UAO 才能閱讀了，而這篇文章是你打的。解決方式便是將這段擴充區移到 Mapping Table 的最後面，讓正常區的字優先權較高。於是最後的 <a href="http://file.yzlin.org/uao_big5uni.txt">Mapping Table 表</a>便誕生了，我在每行最後都有加上 UTF-8 所對應到的字。</p>
<p>最後的比較圖如下：<br />
<a title="Screen_with_different_mapping_table by Yi-Jheng, Lin (Alex), on Flickr" href="http://www.flickr.com/photos/yzlin1985/3019998111/"><img src="http://farm4.static.flickr.com/3212/3019998111_6d8c6c8b50.jpg" alt="Screen_with_different_mapping_table" width="500" height="370" /></a></p>
<p>參考資料：</p>
<ul>
<li>http://moztw.org/docs/big5/</li>
<li><a href="http://uao.cpatch.org">Unicode 補完計畫</a></li>
</ul>
<p>P.S. 其實 UAO 在本意上是良好的，但是作法我不太推崇，畢竟它不是一個標準，只是為了配合 BBS 所產生的過渡產物，所以讓 Screen 支援 UAO 僅是為了讓瀏覽 BBS 文章更方便而已，在其他環境下，我還是建議以 Unicode 為主，畢竟它是一個標準，支援度又高，Big5 就讓它慢慢走向歷史吧！</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yzlin.org/2008/11/11/66/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The Tips of Setting Workstation Environment</title>
		<link>http://blog.yzlin.org/2008/11/11/68/</link>
		<comments>http://blog.yzlin.org/2008/11/11/68/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 18:16:10 +0000</pubDate>
		<dc:creator>yzlin</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[NCTUCS]]></category>
		<category><![CDATA[工作記錄]]></category>
		<category><![CDATA[工具]]></category>
		<category><![CDATA[電腦技術]]></category>
		<category><![CDATA[Finch]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Mutt]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://blog.yzlin.org/?p=68</guid>
		<description><![CDATA[這份投影片是之前在系計中內部分享的，整理了一下 share 出來，裡面有些嘴砲請自動略過 XD。有錯也請指正  
]]></description>
			<content:encoded><![CDATA[<p>這份投影片是之前在系計中內部分享的，整理了一下 <a href="http://file.yzlin.org/the_tips_of_setting_workstation_environment.pdf">share 出來</a>，裡面有些嘴砲請自動略過 XD。有錯也請指正 <img src='http://blog.yzlin.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yzlin.org/2008/11/11/68/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Colorize A 256-Color Mutt</title>
		<link>http://blog.yzlin.org/2008/09/13/60/</link>
		<comments>http://blog.yzlin.org/2008/09/13/60/#comments</comments>
		<pubDate>Sat, 13 Sep 2008 08:56:02 +0000</pubDate>
		<dc:creator>yzlin</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[工具]]></category>
		<category><![CDATA[電腦技術]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Mutt]]></category>

		<guid isPermaLink="false">http://blog.yzlin.org/?p=60</guid>
		<description><![CDATA[Mutt 是一個我很愛用的 Mail Client，除了平常在用的 GMail 外，其他幾乎都是由它包辦，其實之前就知道 Mutt 支援 256-Color，只是一直沒有時間好好調校，昨天趁著颱風天的下午，在 FreeBSD 上把 Mutt 的 256-Color 設定好了。
在預設的 Mutt color setting 中，單純使用常用的 16-Color 就是用 black, green, red, blue, &#8230;, etc 這類的顏色詞來設定；但是在 256-Color 的環境下，必須使用 color0, color1, &#8230;, color254, color255 來做設定，關於顏色的對照表，可以參考這邊。
這邊提供一下我的設定 (看是要放到 $HOME/.muttrc 或是另放一個檔案，再從 $HOME/.muttrc include 進去)：

color normal            default [...]]]></description>
			<content:encoded><![CDATA[<p>Mutt 是一個我很愛用的 Mail Client，除了平常在用的 GMail 外，其他幾乎都是由它包辦，其實之前就知道 Mutt 支援 256-Color，只是一直沒有時間好好調校，昨天趁著颱風天的下午，在 FreeBSD 上把 Mutt 的 256-Color 設定好了。</p>
<p>在預設的 Mutt color setting 中，單純使用常用的 16-Color 就是用 black, green, red, blue, &#8230;, etc 這類的顏色詞來設定；但是在 256-Color 的環境下，必須使用 color0, color1, &#8230;, color254, color255 來做設定，關於顏色的對照表，可以參考<a href="http://vip.cs.nctu.edu.tw/~yzlin/256Color/256-xterm-24bit-rgb-color-chart.html" target="_blank">這邊</a>。</p>
<p>這邊提供一下我的設定 (看是要放到 $HOME/.muttrc 或是另放一個檔案，再從 $HOME/.muttrc include 進去)：</p>
<blockquote>
<pre>color normal            default         default         # normal text
color indicator         color214        color237        # actual message
color tree              color99         default         # thread arrows
color status            color118        color237        # status line
color error             color196        default         # errors
color message           color196        default         # info messages
color signature         brightblack     default         # signature
color attachment        brightblack     default         # MIME attachments
color search            brightyellow    red             # search matches
color tilde             brightmagenta   default         # ~ at bottom of msg
color markers           red             default         # + at beginning of wrapped lines

color hdrdefault        color33         default         # default header lines
color bold              red             default         # hiliting bold patterns in body
color underline         green           default         # hiliting underlined patterns in body

color quoted            color107        default         # quoted text
color quoted1           color66         default
color quoted2           color32         default
color quoted3           color30         default
color quoted4           color99         default
color quoted5           color36         default
color quoted6           color114        default
color quoted7           color109        default
color quoted8           color41         default
color quoted9           color138        default
# header
color header            color205        default         "^(From|Subject|To|Cc|Bcc):"

# body
color body              color214        default         "(http|https|ftp|news|telnet|finger)://[^ ]+"
color body              color81         default         "[-a-z_0-9.+]+@[-a-z_0-9.]+"
color body              red             default         "(^| )\\*[-a-z0-9*]+\\*[,.?]?[ \n]"
color body              green           default         "(^| )_[-a-z0-9_]+_[,.?]?[ \n]"

# index
uncolor index *         # unset all color index entries
color index             brightgreen     default         ~F      # Flagged
color index             color74         default         ~N      # New
color index             color169        default         ~T      # Tagged
color index             brightblack     default         ~D      # Deleted</pre>
</blockquote>
<p>這樣設定完成後，如果你跟我一樣使用 $TERM=xterm，沒意外的話會噴出這樣子的訊息：</p>
<blockquote>
<pre>Error in /home/yzlin/.mutt/color/color256, line 9: 214: color not supported by term
Error in /home/yzlin/.mutt/color/color256, line 10: 99: color not supported by term
Error in /home/yzlin/.mutt/color/color256, line 11: 118: color not supported by term
Error in /home/yzlin/.mutt/color/color256, line 12: 196: color not supported by term
Error in /home/yzlin/.mutt/color/color256, line 13: 196: color not supported by term
Error in /home/yzlin/.mutt/color/color256, line 20: 33: color not supported by term
Error in /home/yzlin/.mutt/color/color256, line 24: 107: color not supported by term
...</pre>
</blockquote>
<p>會出現這樣的問題，是因為 Mutt 使用到 ncurses，會判斷 termcap 中，你所使用的 TERM (在此是 xterm) 是否支援 256-Color，如果不支援那麼高，就會噴出這樣子的訊息，這時候有人就會把 TERM 設成 xterm-256color，如此一來，就會成功！？很遺憾的，照樣噴 XD，在 Linux 下，可以單純只設成 xterm-256color，但是在 FreeBSD 下，卻不行！</p>
<p>為何會有如此的差異？其實這個問題帶有一點點歷史的包袱，FreeBSD 預設使用的是 termcap，而 Linux 多半使用的是 terminfo，也因為如此，FreeBSD termcap 會受限於單一 entry 字元數必須小於 1024 個的限制，如此一來，沒辦法將全部的 feature 都包含進去，xterm-256color 就是一個例子，在 /usr/share/misc/termcap 中有一段說明：</p>
<blockquote>
<pre># These aliases are for compatibility with the terminfo; termcap cannot provide
# the extra features, but termcap applications still want the names.
xterm-16color|xterm alias 1:tc=xterm-xfree86:
xterm-88color|xterm alias 2:tc=xterm-256color:
xterm-256color|xterm alias 3:tc=xterm-xfree86:</pre>
</blockquote>
<p>從說明可以看到 xterm-256color 其實引入的是 xterm-xfree86，再詳細去看，xterm-xfree86 當中並沒有 Co 的設定 (Co 指的是 &#8220;Maximum number of colors on screen&#8221;，相當於 terminfo 中的 colors)，而是引入 xterm-basic 的設定，當中只支援 Co#8，這也是為什麼 xterm-256color 在 FreeBSD 中並不是真的支援 256 色。</p>
<p>若要知道目前使用的 TERM 所支援的 colors，可以使用：</p>
<blockquote>
<pre>tput Co</pre>
</blockquote>
<p>注意不是 co 而是 Co，co 是 columns 的意思。</p>
<p>既然無法針對 termcap 下手，那究竟該如何設定使用 Co#256 呢？好在我們可以自行設定一個環境變數 TERMCAP，來強制指定，在 $HOME/.cshrc 設定：</p>
<blockquote>
<pre>setenv TERMCAP 'xterm|xterm-color:Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm:tc=xterm-xfree86:'</pre>
</blockquote>
<p>由上面的設定，可以看到我們覆寫了 Co、AB、AF，這樣的設定跟 .screenrc 當中的設定很像，AF 指的是 foreground color 的表示方式；AB 則是 backgound color 的表示方式。設定完成如果要確定是否成功，可以利用 tput 去檢查 Co，出現 256 便是表示成功了，接著在這樣的環境下執行 Mutt，沒意外會看到這樣子的畫面：<br />
<a title="mutt-256color by Yi-Jheng, Lin (Alex), on Flickr" href="http://www.flickr.com/photos/yzlin1985/2852995886/"><img src="http://farm4.static.flickr.com/3127/2852995886_c67150a32b.jpg" alt="mutt-256color" width="500" height="357" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yzlin.org/2008/09/13/60/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zsh &#8211; autocomplete error</title>
		<link>http://blog.yzlin.org/2008/09/10/56/</link>
		<comments>http://blog.yzlin.org/2008/09/10/56/#comments</comments>
		<pubDate>Wed, 10 Sep 2008 09:00:57 +0000</pubDate>
		<dc:creator>yzlin</dc:creator>
				<category><![CDATA[工具]]></category>
		<category><![CDATA[電腦技術]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://blog.yzlin.org/?p=56</guid>
		<description><![CDATA[最近開始在嘗試一套蠻強大的 shell &#8211; zsh，我用過的 shell 沒有很多，最常用的還是 tcsh &#38; sh，bash 以前有用過一陣子。試用了一陣子，覺得它真的蠻強的，可以把 prompt 的介面和 auto-complete 的功能弄得很炫。改天再發篇文寫一下自己的設定心得。
這篇主要是講一下之前遇到的一個問題，在 auto-complete 的設定下，會出現：

_alternative:69: command not found: _canonical_paths

雖然好像可以正常運作，但就是覺得怪怪的，後來 google 了一下，發現了別人的解法，原來是 $HOME/.zcompdump 爛掉，把它砍掉，讓 zsh 自動重建就行了。
]]></description>
			<content:encoded><![CDATA[<p>最近開始在嘗試一套蠻強大的 shell &#8211; zsh，我用過的 shell 沒有很多，最常用的還是 tcsh &amp; sh，bash 以前有用過一陣子。試用了一陣子，覺得它真的蠻強的，可以把 prompt 的介面和 auto-complete 的功能弄得很炫。改天再發篇文寫一下自己的設定心得。</p>
<p>這篇主要是講一下之前遇到的一個問題，在 auto-complete 的設定下，會出現：</p>
<blockquote>
<pre>_alternative:69: command not found: _canonical_paths</pre>
</blockquote>
<p>雖然好像可以正常運作，但就是覺得怪怪的，後來 google 了一下，發現了別人的解法，原來是 $HOME/.zcompdump 爛掉，把它砍掉，讓 zsh 自動重建就行了。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yzlin.org/2008/09/10/56/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make Your VIM &amp; Screen Environment Comfortable</title>
		<link>http://blog.yzlin.org/2008/08/20/53/</link>
		<comments>http://blog.yzlin.org/2008/08/20/53/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 07:27:49 +0000</pubDate>
		<dc:creator>yzlin</dc:creator>
				<category><![CDATA[工具]]></category>
		<category><![CDATA[電腦技術]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://blog.yzlin.org/?p=53</guid>
		<description><![CDATA[這份 slide 是之前在 Y 社內部 Intern Sharing 所準備的，算是小技巧大集合，分享出來給大家，希望會有幫助。
裡面提到的大多都是建立在「我所認為舒服的環境」的前提上所給的技巧和設定；每個人有每個人認為舒服的設定，這是很主觀的，所以純粹只是當參考。
]]></description>
			<content:encoded><![CDATA[<p><a href="http://vip.cs.nctu.edu.tw/~yzlin/slide/make_your_vim_and_screen_env_comfortable.pdf">這份 slide</a> 是之前在 Y 社內部 Intern Sharing 所準備的，算是小技巧大集合，分享出來給大家，希望會有幫助。</p>
<p>裡面提到的大多都是建立在<strong>「我所認為舒服的環境」</strong>的前提上所給的技巧和設定；每個人有每個人認為舒服的設定，這是很主觀的，所以純粹只是當參考。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yzlin.org/2008/08/20/53/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
