分享
 
 
 

solaris让ls命令显示颜色

王朝other·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

去 sunfreeware.com 下载 coreutils-4.5.4-sol9-sparc-local.gz

Coloured ls output in 10 steps

Always dreamt of having the same sort of output on your Solaris machine as you would have on Linux? Here is how you go at that.

1. Coloured output is a feature of the GNU version of ls. So you first have to obtain this version. GNU ls is in the coreutils package. You can download it from (a mirror) of sunfreeware.com.

2. Install the package using the pkgadd command:

root@host /var/tmp> pkgadd -d coreutils-4.5.4-sol9-sparc-local

The following packages are available:

1 SMCcoreu coreutils

(sparc) 4.5.4

Select package(s) you wish to process (or 'all' to process

all packages). (default: all) [?,??,q]: y

--output ommitted--

3. This will install GNU ls and some other useful GNU programs in /usr/local/bin. Check this directory.

4. Information about the commands can be found in /usr/local/doc and /usr/local/man. Read the documentation for the new commands, e.g. for dircolors:

user@host ~> man -M /usr/local/man dircolors

Lateron, make sure that the MANPATH variable includes /usr/local/man.

5. Colours can also be set system wide, in that case you need a DIR_COLORS file in /etc. It may look somewhat like this:

user@host ~> cat /etc/DIR_COLORS

# Configuration file for the color ls utility

# This file goes in the /etc directory, and must be world readable.

# You can copy this file to .dir_colors in your $HOME directory to override

# the system defaults.

# COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not

# pipes. 'all' adds color characters to all output. 'none' shuts colorization

# off.

COLOR tty

# Extra command line options for ls go here.

# Basically these ones are:

# -F = show '/' for dirs, '*' for executables, etc.

# -T 0 = don't trust tab spacing when formatting ls output.

OPTIONS -F -T 0

# Below, there should be one TERM entry for each termtype that is colorizable

TERM linux

TERM console

TERM con132x25

TERM con132x30

TERM con132x43

TERM con132x60

TERM con80x25

TERM con80x28

TERM con80x30

TERM con80x43

TERM con80x50

TERM con80x60

TERM cons25

TERM xterm

TERM rxvt

TERM xterm-color

TERM color-xterm

TERM vt100

TERM dtterm

TERM color_xterm

# EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)

EIGHTBIT 1

# Below are the color init strings for the basic file types. A color init

# string consists of one or more of the following numeric codes:

# Attribute codes:

# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed

# Text color codes:

# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white

# Background color codes:

# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white

NORMAL 00 # global default, although everything should be something.

FILE 00 # normal file

DIR 01;34 # directory

LINK 01;36 # symbolic link

FIFO 40;33 # pipe

SOCK 01;35 # socket

BLK 40;33;01 # block device driver

CHR 40;33;01 # character device driver

ORPHAN 01;05;37;41 # orphaned syminks

MISSING 01;05;37;41 # ... and the files they point to

# This is for files with execute permission:

EXEC 01;32

# List any file extensions like '.gz' or '.tar' that you would like ls

# to colorize below. Put the extension, a space, and the color init string.

# (and any comments you want to add after a '#')

.cmd 01;32 # executables (bright green)

.exe 01;32

.com 01;32

.btm 01;32

.bat 01;32

.sh 01;32

.csh 01;32

.tar 01;31 # archives or compressed (bright red)

.tgz 01;31

.arj 01;31

.taz 01;31

.lzh 01;31

.zip 01;31

.z 01;31

.Z 01;31

.gz 01;31

.bz2 01;31

.bz 01;31

.tz 01;31

.rpm 01;31

.cpio 01;31

.jpg 01;35 # image formats

.gif 01;35

.bmp 01;35

.xbm 01;35

.xpm 01;35

.png 01;35

.tif 01;35

6. Test that your new setup works, using the /usr/local/bin/ls --color command in a couple of directories.

If your colours seem ok (look also at other than plain text files), proceed to the next step.

7. Now we don't want to type /usr/local/bin/ls --color all the time. You can solve the problem by altering your PATH variable:

user@host ~> export PATH=/usr/local/bin:$PATH

This way, when you just type ls, the first occurance in your search path will be the ls from /usr/local/bin instead of the default one from /usr/bin.

8. Now we already have the correct program when we call it, but we are lazier than that, because we don't want to type the --color option all the time either. So you might want to alias the ls command:

user@host ~> alias ls='ls --color'

Mind that this does not work for the common shell, /sbin/sh. You need a more advanced shell for making aliases, such as bash or ksh.

9. Of course, when you log out, all these settings are gone, so add these lines to your shell configuration file, e.g. ~/.bashrc:

user@host ~> echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bashrc

user@host ~> echo "alias ls='ls --color'" >> ~/.bashrc

10. In order to make these settings available for all users on the system, put these last two lines in /etc/profile (check first, if PATH is already defined, it is cleaner to arrange the existing definition.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有