修改 文件和文件夹的颜色主要是要修改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变量代表的内容就是用户名+主机名+路径名(长路径)+ $。
首先我们要知道如下几张表:
前景 背景 颜色
---------------------------------------
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 不可见
序列说明
\a ASCII响铃字符(也可以键入 \007)
\d "Wed Sep 06"格式的日期
\e ASCII转义字符(也可以键入 \033)
\h 主机名的第一部分(如 "mybox")
\H 主机的全称(如 "mybox.mydomain.com")
\j 在此 shell中通过按 ^Z挂起的进程数
\l 此 shell的终端设备名(如 "ttyp4")
\n 换行符
\r 回车符
\s shell的名称(如 "bash")
\t 24小时制时间(如 "23:01:01")
\T 12小时制时间(如 "11:01:01")
\@ 带有 am/pm的 12小时制时间
\u 用户名
\v bash的版本(如 2.04)
\V Bash版本(包括补丁级别) ?/td>;
\w 当前工作目录(如 "/home/drobbins")
\W 当前工作目录的“基名 (basename)”(如 "drobbins")
\! 当前命令在历史缓冲区中的位置
\# 命令编号(只要您键入内容,它就会在每次提示时累加)
\$ 如果您不是超级用户 (root),则插入一个 "$";如果您是超级用户,则显示一个 "#"
\xxx 插入一个用三位数 xxx(用零代替未使用的数字,如 "/007")表示的 ASCII 字符
\\ 反斜杠
\[这个序列应该出现在不移动光标的字符序列(如颜色转义序列)之前。它使 bash能够正确计算自动换行。
\] 这个序列应该出现在非打印字符序列之后。
经过对上面的了解我们可以直接对.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‘
原文:https://www.cnblogs.com/anyiz/p/10657029.html