修改 文件和文件夹的颜色主要是要修改root目录下的.bashrc文件的内容!
没有修改前.bashrc文件内容为如下:
# ~/.bashrc: executed by bash(1) for non-login shells.
# Note: PS1 and umask are already set in /etc/profile. You should not
# need this unless you want different defaults for root.
# PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '
# You may uncomment the following lines if you want `ls' to be colorized:
#export LS_OPTIONS='--color=auto'
#eval "`dircolors`"
#alias ls='ls $LS_OPTIONS'
#alias ll='ls $LS_OPTIONS -l'
#alias l='ls $LS_OPTIONS -lA'
#
# Some more alias to avoid making mistakes:
#alias rm='rm -i'
#alias cp='cp -i'
# alias mv='mv -i'
颜色的修改主要有PS1决定,PS1变量代表的内容就是用户名+主机名+路径名(长路径)+ $。
首先我们要知道如下几张表:
1
序列说明
\a ASCII响铃字符(也可以键入
\d "Wed Sep 06"格式的日期
\e ASCII转义字符(也可以键入
\h
\H
\j
\l
\n
\r
\s shell的名称(如
\t 24小时制时间(如
\T 12小时制时间(如
\@
\u
\v bash的版本(如
\V Bash版本(包括补丁级别)
\w
\W
\!
\#
\$
\xxx
\\
\[这个序列应该出现在不移动光标的字符序列(如颜色转义序列)之前。它使
\]
经过对上面的了解我们可以直接对.bashrc文件设置为
# ~/.bashrc: executed by bash(1) for non-login shells.
# Note: PS1 and umask are already set in /etc/profile. You should not
# need this unless you want different defaults for root.
# PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '
export PS1='\[\033[4;31;40m\]\u\[\033[00m\]@\h:\[\033[37;40m\]\w\[\033[32;40m\]\$ \[\033[34;40m\]'
umask 022
# You may uncomment the following lines if you want `ls' to be colorized:
export LS_OPTIONS='--color=auto'
eval "`dircolors`"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'
#
# Some more alias to avoid making mistakes:
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
断开连接重新用ssh终端登录发现颜色改变了!!