Ubuntu终端配色
在用ubuntu的时候默认终端只能显示一种颜色,对于路径,文件不好区分,所以我们来设置下让它显示这样的效果
用户主机为红,路径为绿色,777文件夹标绿等等…
How do
1.打开.bashrc,最后一行添加如下脚本
1 |
$ gedit ~/.bashrc |
1 2 3 4 5 |
PS1='${debian_chroot:+($debian_chroot)}\[\033[00;31;01m\]\u\[\033[00;37;01m\]@\[\033[00;31;01m\]\h\[\033[01;37;01m\]:\[\033[00;00;01m\]\w \[\033[00;34;01m\]\$ \[\033[00;00;01m\]' if [ "$TERM" != "dumb" ]; then eval "`dircolors -b`" alias ls='ls -bF --color=always' fi |
2.在用户目录下新建.dir_colors文件,添加以下代码
1 |
$ gedit ~/.dir_colors |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# 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 all # 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 urxvt TERM xterm-color TERM color-xterm TERM vt100 TERM dtterm TERM color_xterm TERM ansi TERM screen TERM aterm TERM kterm TERM gnome-terminal TERM xfce-terminal # 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;36 # directory LINK 01;34 # 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 .deb 01;31 .cpio 01;31 .7z 01;31 .jpg 01;35 # image formats .jpeg 01;35 .JPG 01;35 .JPEG 01;35 .gif 01;35 .GIF 01;35 .bmp 01;35 .BMP 01;35 .xbm 01;35 .XBM 01;35 .xpm 01;35 .XPM 01;35 .png 01;35 .PNG 01;35 .mng 01;35 .MNG 01;35 .tif 01;35 .tiff 01;35 .TIF 01;35 .TIFF 01;35 |
代码解释:
PS1为终端显示设置
1 2 |
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' PS1变量代表 用户名+主机名+路径名(长路径)+ $ |
颜色为一一对应
1 2 |
\[\ 033[01;32;40m\] [代码色;前景色;背景色m\] |
配色对应表为
前景 背景 颜色
30 40 黑色
31 41 紅色
32 42 綠色
33 43 黃色
34 44 藍色
35 45 紫紅色
36 46 青藍色
37 47 白色
1 透明色
代码
0 OFF
1 高亮显示
4 underline
5 闪烁
7 反白显示
8 不可见
if…fi 为ls 显示颜色设置,.dir_color为配色文件
over…
Referrnces:
http://www.tuicool.com/articles/NRZfIj
http://ubuntuforums.org/showthread.php?t=842840&s=ba30f2a53cb0d9978533f724915bc100&p=5277375#post5277375
暂无评论