archlinux改变终端文字的颜色提高效率.docx

上传人:b****5 文档编号:5022908 上传时间:2022-12-12 格式:DOCX 页数:9 大小:17.95KB
下载 相关 举报
archlinux改变终端文字的颜色提高效率.docx_第1页
第1页 / 共9页
archlinux改变终端文字的颜色提高效率.docx_第2页
第2页 / 共9页
archlinux改变终端文字的颜色提高效率.docx_第3页
第3页 / 共9页
archlinux改变终端文字的颜色提高效率.docx_第4页
第4页 / 共9页
archlinux改变终端文字的颜色提高效率.docx_第5页
第5页 / 共9页
点击查看更多>>
下载资源
资源描述

archlinux改变终端文字的颜色提高效率.docx

《archlinux改变终端文字的颜色提高效率.docx》由会员分享,可在线阅读,更多相关《archlinux改变终端文字的颜色提高效率.docx(9页珍藏版)》请在冰豆网上搜索。

archlinux改变终端文字的颜色提高效率.docx

archlinux改变终端文字的颜色提高效率

archlinux改变终端文字的颜色,提高效率

archlinux改变终端文字的颜色,提高效率。

sjwkwang_发布于2011-5-04默认情况下,archlinux的终端显示的是黑白的。

比如root@arch:

~#都是黑白的,偶尔在往回看时,不容易很快找到root@arch:

~#。

root下ls出来的也是黑白的,不能直观的分辨出哪个是文件夹哪个是文件。

浪费时间。

而在gentoo下花花绿绿的很是直观。

下面是我发现的怎么改变终端颜色的方法,在archlinux下改变方法和ubuntu和debian的改变方法有一点点不同。

一,改变普通用户:

编辑.bashrc,添加PS1='${arch_chroot:

+($arch_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:

\[\033[01;34m\]\w\[\033[00m\]\$'

二,改变root,:

编辑/etc/bash.bashrc,添加aliasls='ls--color=auto'

与PS1='${arch_chroot:

+($arch_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:

\[\033[01;34m\]\w\[\033[00m\]\$'前者使ls出来的是彩色的,好分辨文件类型。

后者使root@arch:

~变的彩色颜色及相关数值:

30(黑色)、31(红色)、32(绿色)、33(黄色)、34(蓝色)、35(紫红色)、36(青色)、37(白色)注意:

在编辑完后要重新打开终端才能生效。

改变后的效果见附图。

######################################################################################

方法二:

其实可以直接用gentoo的来替换arch的,显示效果会更好。

1,改变普通用户的:

用gentoo中的.bashrc文件中的内容替换.bashrc里的全部内容

2,改变root用户的:

用gentoo中的/etc/bash/bashrc文件中的内容替换/etc/bash.bashrc中的全部内容。

同样是重新打开终端。

效果见附图。

gentoo的.bashrcCODE:

#/etc/skel/.bashrc

#

#Thisfileissourcedbyall*interactive*bashshellsonstartup,

#includingsomeapparentlyinteractiveshellssuchasscpandrcp

#thatcan'ttolerateanyoutput.Somakesurethisdoesn'tdisplay

#anythingorbadthingswillhappen!

#Testforaninteractiveshell.Thereisnoneedtosetanything

#pastthispointforscpandrcp,andit'simportanttorefrainfrom

#outputtinganythinginthosecases.

if[[$-!

=*i*]];then

#Shellisnon-interactive.Bedonenow!

return

fi#Putyourfunstuffhere.

gentoo的/etc/bash/bashrcCODE:

#/etc/bash/bashrc

#

#Thisfileissourcedbyall*interactive*bashshellsonstartup,

#includingsomeapparentlyinteractiveshellssuchasscpandrcp

#thatcan'ttolerateanyoutput.Somakesurethisdoesn'tdisplay

#anythingorbadthingswillhappen!

#Testforaninteractiveshell.Thereisnoneedtosetanything

#pastthispointforscpandrcp,andit'simportanttorefrainfrom

#outputtinganythinginthosecases.

if[[$-!

=*i*]];then

#Shellisnon-interactive.Bedonenow!

return

fi#Bashwon'tgetSIGWINCHifanotherprocessisintheforeground.

#Enablecheckwinsizesothatbashwillchecktheterminalsizewhen

#itregainscontrol.#65623

#s.cwru.edu/~chet/bash/FAQ(E11)

shopt-scheckwinsize#Enablehistoryappendinginsteadofoverwriting.#139609

shopt-shistappend#ChangethewindowtitleofXterminals

case${TERM}in

xterm*|rxvt*|Eterm|aterm|kterm|gnome*|interix)

PROMPT_COMMAND='echo-ne"\033]0;${USER}@${HOSTNAME%%.*}:

${PWD/#$HOME/~}\007"'

;;

screen)

PROMPT_COMMAND='echo-ne"\033_${USER}@${HOSTNAME%%.*}:

${PWD/#$HOME/~}\033\\"'

;;

esacuse_color=false#SetcolorfulPS1onlyoncolorfulterminals.

#dircolors--print-databaseusesitsownbuilt-indatabase

#insteadofusing/etc/DIR_COLORS.Trytousetheexternalfile

#firsttotakeadvantageofuseradditions.Useinternalbash

#globbinginsteadofexternalgrepbinary.

safe_term=${TERM//[^[:

alnum:

]]/?

}#sanitizeTERM

match_lhs=""

[[-f~/.dir_colors]]&&match_lhs="${match_lhs}$(<~/.dir_colors)"

[[-f/etc/DIR_COLORS]]&&match_lhs="${match_lhs}$(</etc/DIR_COLORS)"

[[-z${match_lhs}]]\

&&type-Pdircolors>/dev/null\

&&match_lhs=$(dircolors--print-database)

[[\n'${match_lhs}==*\n'"TERM"${safe_term}*]]&&use_color=trueif${use_color};then

#Enablecolorsforls,etc.Prefer~/.dir_colors#64489

iftype-Pdircolors>/dev/null;then

if[[-f~/.dir_colors]];then

eval$(dircolors-b~/.dir_colors)

elif[[-f/etc/DIR_COLORS]];then

eval$(dircolors-b/etc/DIR_COLORS)

fi

fiif[[${EUID}==0]];then

PS1='\[\033[01;31m\]\h\[\033[01;34m\]\W\$\[\033[00m\]'

else

PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\]\w\$\[\033[00m\]'

fialiasls='ls--color=auto'

aliasgrep='grep--colour=auto'

else

if[[${EUID}==0]];then

#showroot@whenwedon'thavecolors

PS1='\u@\h\W\$'

else

PS1='\u@\h\w\$'

fi

fi#Trytokeepenvironmentpollutiondown,EPAlovesus.

unsetuse_colorsafe_termmatch_lhs

archlinux官方wiki上的說明:

Generalizingcolorsforallusers

Ifyouwanttogeneralizetheuseofcolorsforallusersinthesystem,youmustmodifythe/etc/bash.bashrcfileandcreatea/etc/DIR_COLORSfile.HereisapossiblegeneralizationoftheGentoocolorschemeforArchlinux:

/etc/bash.bashrc:

#/etc/bash.bashrc

#

#https:

//wiki.archlinux.org/index.php/Color_Bash_Prompt

#

#Thisfileissourcedbyall*interactive*bashshellsonstartup,

#includingsomeapparentlyinteractiveshellssuchasscpandrcp

#thatcan'ttolerateanyoutput.Somakesurethisdoesn'tdisplay

#anythingorbadthingswillhappen!

#Testforaninteractiveshell.Thereisnoneedtosetanything

#pastthispointforscpandrcp,andit'simportanttorefrainfrom

#outputtinganythinginthosecases.if[[$-!

=*i*]];then

#Shellisnon-interactive.Bedonenow!

return

fi#Bashwon'tgetSIGWINCHifanotherprocessisintheforeground.

#Enablecheckwinsizesothatbashwillchecktheterminalsizewhen

#itregainscontrol.#65623

#s.cwru.edu/~chet/bash/FAQ(E11)

shopt-scheckwinsize#Enablehistoryappendinginsteadofoverwriting.#139609

shopt-shistappendcase${TERM}in

xterm*|rxvt*|Eterm|aterm|kterm|gnome*)

PROMPT_COMMAND=${PROMPT_COMMAND:

+$PROMPT_COMMAND;}'printf"\033]0;%s@%s:

%s\007""${USER}""${HOSTNAME%%.*}""${PWD/#$HOME/~}"'

;;

screen)

PROMPT_COMMAND=${PROMPT_COMMAND:

+$PROMPT_COMMAND;}'printf"\033_%s@%s:

%s\033\\""${USER}""${HOSTNAME%%.*}""${PWD/#$HOME/~}"'

;;

esac#Fortuneisasimpleprogramthatdisplaysapseudorandommessage

#fromadatabaseofquotationsatlogonand/orlogout;

#type:

"pacman-Sfortune-mod"toinstallit,thenuncommentthe

#followinglines:

#if["$PS1"];then

#/usr/bin/fortune

#fi#SetcolorfulPS1onlyoncolorfulterminals.

#dircolors--print-databaseusesitsownbuilt-indatabase

#insteadofusing/etc/DIR_COLORS.Trytousetheexternalfile

#firsttotakeadvantageofuseradditions.Useinternalbash

#globbinginsteadofexternalgrepbinary.#Dynamicallymodifiedvariables.Donotchangethem!

use_color=false

#sanitizeTERM:

safe_term=${TERM//[^[:

alnum:

]]/?

}

match_lhs=""[[-f~/.dir_colors]]&&match_lhs="${match_lhs}$(<~/.dir_colors)"

[[-f/etc/DIR_COLORS]]&&match_lhs="${match_lhs}$(</etc/DIR_COLORS)"

[[-z${match_lhs}]]&&type-Pdircolors>/dev/null&&match_lhs=$(dircolors--print-database)

[[$'\n'${match_lhs}==*$'\n'"TERM"${safe_term}*]]&&use_color=trueif${use_color};then

#Enablecolorsforls,etc.Prefer~/.dir_colors#64489

iftype-Pdircolors>/dev/null;then

if[[-f~/.dir_colors]];then

eval$(dircolors-b~/.dir_colors)

elif[[-f/etc/DIR_COLORS]];then

eval$(dircolors-b/etc/DIR_COLORS)

fi

fiif[[${EUID}==0]];then

PS1='\[\033[01;31m\]\h\[\033[01;34m\]\W\$\[\033[00m\]'

else

PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\]\w\$\[\033[00m\]'

fialiasls='ls--color=auto'

aliasdir='dir--color=auto'

aliasgrep='grep--colour=auto'

else

if[[${EUID}==0]];then

#showroot@whenwedonothavecolors

PS1='\u@\h\W\$'

else

PS1='\u@\h\w\$'

fi

fiPS2='>'

PS3='>'

PS4='+'#Trytokeepenvironmentpollutiondown,EPAlovesus.

unsetuse_colorsafe_termmatch_lhs[-r/etc/bash_completion]&&./etc/bash_completion

/etc/DIR_COLORS:

#Configurationfileforthecolorlsutility

#Thisfilegoesinthe/etcdirectory,andmustbeworldreadable.

#Youcancopythisfileto.dir_colorsinyour$HOMEdirectorytooverride

#thesystemdefaults.#COLORneedsoneofthesearguments:

'tty'colorizesoutputtottys,butnot

#pipes.'all'addscolorcharacterstoalloutput.'none'shutscolorization

#off.

COLORall#Extracommandlineoptionsforlsgohere.

#Basicallytheseonesare:

#-F=show'/'fordirs,'*'forexecutables,etc.

#-T0=don'ttrusttabspacingwhenformattinglsoutput.

OPTIONS-F-T0#Below,thereshouldbeoneTERMentryforeachtermtypethatiscolorizable

TERMlinux

TERMconsole

TERMcon132x25

TERMcon132x30

TERMcon132x43

TERMcon132x60

TERMcon80x25

TERMcon80x28

TERMcon80x30

TERMcon80x43

TERMcon80x50

TERMcon80x60

TERMxterm

TERMvt100

TERMrxvt

TERMrxvt-256color

TERMrxvt-cygwin

TERMrxvt-cygwin-native

TERMrxvt-unicode

TERMrxvt-unicode-256color

TERMrxvt-unicode256#EIGHTBIT,followedby'1'foron,'0'foroff.(8-bitoutput)

EIGHTBIT1#Belowarethecolorinitstringsforthebasicfiletypes.Acolorinit

#stringconsistsofoneormoreofthefollowingnumericcodes:

#Attributecodes:

#00=none01=bold04=underscore05=blink07=reverse08=concealed

#Textcolorcodes:

#30=black31=red32=green33=yellow34=blue35=magenta36=cyan37=white

#Backgroundcolorcodes:

#40=black41=red42=green43=yellow44=blue45=magenta46=cyan47=white

NORMAL00#globaldefault,althougheverythingshouldbesomething.

FILE00#normalfile

DIR01;34#directory

LINK01;36#symboliclink

FIFO40;33#pipe

SOCK01;35#socket

BLK40;33;01#blockdevicedriver

CHR40;33;01#characterdevicedriver#Thisisforfileswithexecutepermission:

EXEC01;32#Listanyfileextensionslike'.gz'or'.tar'thatyouwouldlikels

#tocolorizebelow.Puttheextension,aspace,andthecolorinitstring.

#(andanycommentsyouwanttoaddaftera'#')

.cmd01;32#executables(brightgreen)

.exe01;32

.com01;32

.btm01;32

.bat01;32

.tar01;31#archivesorcompressed(brightred)

.tgz01;31

.arj01;31

.taz01;31

.lzh01;31

.zip01;31

.z01;31

.Z01;31

.gz01;31

.jpg01;35#imageformats

.gif01;35

.bmp01;35

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 军事

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1