less可以显示彩色字符吗?

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
头像
pityonline
帖子: 3864
注册时间: 2008-12-09 12:44
来自: 北京
联系:

less可以显示彩色字符吗?

#1

帖子 pityonline » 2009-12-12 19:27

我们知道vim可以显示彩色字符,ls也可以,那么less可以显示彩色字符吗?
Pity is the bomp!
活着就是折腾!生命不息,折腾不止!
看这帮家伙在干什么?@pityonline/u
Dropbox+Vps+PC 跑起来了!这是邀请链接
头像
O_O_BOT
帖子: 2461
注册时间: 2009-05-20 19:32

Re: less可以显示彩色字符吗?

#2

帖子 O_O_BOT » 2009-12-12 19:37

irc <roylez> say: less -R
irc 聊天室
ubuntu-cn 的irc 频道为
irc.ubuntu.com 8001 #ubuntu-cn
UTF8编码 可用 irssi xchat pidgin weechat 登录

http://webchat.freenode.net/?channels=ubuntu-cn
[url]irc://irc.freenode.net/ubuntu-cn[/url]
头像
pityonline
帖子: 3864
注册时间: 2008-12-09 12:44
来自: 北京
联系:

Re: less可以显示彩色字符吗?

#3

帖子 pityonline » 2009-12-12 20:17

O_O_BOT 写了:irc <roylez> say: less -R
It seems not work....
Pity is the bomp!
活着就是折腾!生命不息,折腾不止!
看这帮家伙在干什么?@pityonline/u
Dropbox+Vps+PC 跑起来了!这是邀请链接
nelsonie
帖子: 50
注册时间: 2009-11-25 10:13

Re: less可以显示彩色字符吗?

#4

帖子 nelsonie » 2009-12-12 22:29

-D [xn.n] . --color=xn.n
Set screen colors. (MS-DOS only)
查了下help,貌似不行
头像
pityonline
帖子: 3864
注册时间: 2008-12-09 12:44
来自: 北京
联系:

Re: less可以显示彩色字符吗?

#5

帖子 pityonline » 2009-12-12 22:50

代码: 全选

-Dxcolor or --color=xcolor
              [MS-DOS  only] Sets the color of the text displayed.  x is a single character which
              selects the type of text whose color is being set:  n=normal,  s=standout,  d=bold,
              u=underlined,  k=blink.   color  is  a  pair of numbers separated by a period.  The
              first number selects the foreground color and the  second  selects  the  background
              color of the text.  A single number N is the same as N.0.
试着把x换成n,s,d,u,k都不行,到底是什么格式呢?
Pity is the bomp!
活着就是折腾!生命不息,折腾不止!
看这帮家伙在干什么?@pityonline/u
Dropbox+Vps+PC 跑起来了!这是邀请链接
头像
pityonline
帖子: 3864
注册时间: 2008-12-09 12:44
来自: 北京
联系:

Re: less可以显示彩色字符吗?

#6

帖子 pityonline » 2009-12-13 17:33

hello,大家有知道如何让less也显示彩色字符的吗?
Pity is the bomp!
活着就是折腾!生命不息,折腾不止!
看这帮家伙在干什么?@pityonline/u
Dropbox+Vps+PC 跑起来了!这是邀请链接
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: less可以显示彩色字符吗?

#7

帖子 eexpress » 2009-12-13 17:36

● type less
less 已被别名为“/usr/share/vim/vim72/macros/less.sh”
● 鸣学
头像
roylez
帖子: 1928
注册时间: 2005-10-04 10:59
来自: 上海

Re: less可以显示彩色字符吗?

#8

帖子 roylez » 2009-12-13 17:37

eexpress 写了:● type less
less 已被别名为“/usr/share/vim/vim72/macros/less.sh”
这个慢的。
弄个dropbox空间来备份文件或者做私人代码服务器
配置:[url]git://github.com/roylez/dotfiles.git[/url]
主页:http://roylez.heroku.com
各种稀奇玩意儿:http://dooloo.info
头像
the_comer
帖子: 264
注册时间: 2009-07-08 17:33

Re: less可以显示彩色字符吗?

#9

帖子 the_comer » 2009-12-13 17:40

less好像没有。。。[MS-DOS only],man出来的。。。
-Dxcolor or --color=xcolor
[MS-DOS only] Sets the color of the text displayed
头像
roylez
帖子: 1928
注册时间: 2005-10-04 10:59
来自: 上海

Re: less可以显示彩色字符吗?

#10

帖子 roylez » 2009-12-13 17:40

代码: 全选

export LESS_TERMCAP_md=$'\E[1;31m'      #bold1
export LESS_TERMCAP_mb=$'\E[1;31m'
export LESS_TERMCAP_me=$'\E[m'
export LESS_TERMCAP_so=$'\E[01;44;33m'  #search highlight
export LESS_TERMCAP_se=$'\E[m'
export LESS_TERMCAP_us=$'\E[1;2;32m'    #bold2
export LESS_TERMCAP_ue=$'\E[m'
export LESS="-M -i -R --shift 5"
export LESSCHARSET=utf-8
[ -x /usr/bin/src-hilite-lesspipe.sh ] && export LESSOPEN="| src-hilite-lesspipe.sh %s"
图片
弄个dropbox空间来备份文件或者做私人代码服务器
配置:[url]git://github.com/roylez/dotfiles.git[/url]
主页:http://roylez.heroku.com
各种稀奇玩意儿:http://dooloo.info
头像
pityonline
帖子: 3864
注册时间: 2008-12-09 12:44
来自: 北京
联系:

Re: less可以显示彩色字符吗?

#11

帖子 pityonline » 2009-12-13 17:41

eexpress 写了:● type less
less 已被别名为“/usr/share/vim/vim72/macros/less.sh”
nice!乘神在的时候说话就是管事儿,还带行号的……

感谢!
Pity is the bomp!
活着就是折腾!生命不息,折腾不止!
看这帮家伙在干什么?@pityonline/u
Dropbox+Vps+PC 跑起来了!这是邀请链接
头像
pityonline
帖子: 3864
注册时间: 2008-12-09 12:44
来自: 北京
联系:

Re: less可以显示彩色字符吗?

#12

帖子 pityonline » 2009-12-13 17:52

主席给的代码要放哪个文件里?麻烦说一声……
Pity is the bomp!
活着就是折腾!生命不息,折腾不止!
看这帮家伙在干什么?@pityonline/u
Dropbox+Vps+PC 跑起来了!这是邀请链接
头像
roylez
帖子: 1928
注册时间: 2005-10-04 10:59
来自: 上海

Re: less可以显示彩色字符吗?

#13

帖子 roylez » 2009-12-13 17:58

.bashrc

你需要装一个软件,arch里面叫source-highlight,ubuntu底下你自己查。
弄个dropbox空间来备份文件或者做私人代码服务器
配置:[url]git://github.com/roylez/dotfiles.git[/url]
主页:http://roylez.heroku.com
各种稀奇玩意儿:http://dooloo.info
头像
den
帖子: 196
注册时间: 2007-06-15 21:19
来自: 上海

Re: less可以显示彩色字符吗?

#14

帖子 den » 2009-12-13 18:05

less -R不会像vim一样进行代码高亮,而是可以解析ansi的颜色代码
如果你装了colordiff,可以感受一下less -R
diff xxx | colordiff | less -R
/****************************************************
/* Work hard, play harder.
/****************************************************
头像
pityonline
帖子: 3864
注册时间: 2008-12-09 12:44
来自: 北京
联系:

Re: less可以显示彩色字符吗?

#15

帖子 pityonline » 2009-12-13 18:16

roylez 写了:

代码: 全选

export LESS_TERMCAP_md=$'\E[1;31m'      #bold1
export LESS_TERMCAP_mb=$'\E[1;31m'
export LESS_TERMCAP_me=$'\E[m'
export LESS_TERMCAP_so=$'\E[01;44;33m'  #search highlight
export LESS_TERMCAP_se=$'\E[m'
export LESS_TERMCAP_us=$'\E[1;2;32m'    #bold2
export LESS_TERMCAP_ue=$'\E[m'
export LESS="-M -i -R --shift 5"
export LESSCHARSET=utf-8
[ -x /usr/bin/src-hilite-lesspipe.sh ] && export LESSOPEN="| src-hilite-lesspipe.sh %s"
图片
roylez 写了:.bashrc

你需要装一个软件,arch里面叫source-highlight,ubuntu底下你自己查。
ubuntu下也叫source-highlight,装上了。我把上面那段代码放了进去,发现less没有显示语法高亮。然后看了一下/usr/bin目录下没有src-hilite-lesspipe.sh,只有source-highlight,于是我就替换了,发现还是不行,运行时提示:

代码: 全选

Processing cron.back ... source-highlight: could not find a language definition for input file cron.back
man了一下source-highlight的用法,发现好像要有inputfile和outputfile一类的东西,还有一大堆,是不是需要定义一种语法?

ps:一个小惊喜,man倒是彩色的了……
上次由 pityonline 在 2009-12-13 18:24,总共编辑 1 次。
Pity is the bomp!
活着就是折腾!生命不息,折腾不止!
看这帮家伙在干什么?@pityonline/u
Dropbox+Vps+PC 跑起来了!这是邀请链接
回复