1. 程式人生 > >使linux終端顯示256色

使linux終端顯示256色

Matt Wozniski wrote an awesome little Vim plugin called CSApprox that lets Vim transparently apply GVim colorschemes in the terminal. CSApprox works by approximating the color in the GVim colorscheme to the closest availble color in your terminal, provided that your terminal supports either 88 or 256 colors.

After downloading the plugin zip and extracting it to the ~/.vim directory, I was met with a rather disappointing message:

CSApprox skipped; terminal only has 8 colors, not 88/256
Try checking :help csapprox-terminal for workarounds

Don’t worry, GNOME Terminal isn’t actually limited to 8 colors, it just evades detection. We can easily force 256 color support by setting the t_Co option in ~/.vimrc .

Here is a screenshot of the GVim colorscheme jellybeans.vim running inside of GNOME Terminal.

The GVim colorscheme jellybeans.vim in GNOME Terminal

Pretty. No?

Edit: I need to make a minor retraction: jellybeans.vim already supports 256 color terminals, so we’re only seeing the effect of set t_Co=256(在.vimrc中新增set t_Co=256) here and not CSApprox. In demoing this I picked the nicest scheme I had for GVim, not realizing it already supported 256 color vim. Enjoy anyway =). 

自己的話:

     這是很久以前看到的文章了,當時在ubuntu上面沒有任何問題。後來用了rhel5.2,發現vim在終端下還是不能自由運用絢爛的主題,當時的錯誤提示記不清了,但是涉及到vim元件中的GUI支援問題(像ubuntu和fedora之類更新比較快的版本沒有這樣的問題)。在谷歌上搜索了一下,也有解決的方法,最簡單的就是安裝最新版本的vim,還有就是把vim變成gvim文字模式的符號連結。