bash终端显示配置
1、更改用户和git显示
- vim ~/.bashrc
- 将一下内容添加到.bashrc文件中
function git_branch {
branch="`git branch 2>/dev/null | grep "^\*" | sed -e "s/^\*\ //"`"
if [ "${branch}" != "" ];then
if [ "${branch}" = "(no branch)" ];then
branch="(`git rev-parse --short HEAD`...)"
fi
echo " [*$branch]"
fi
}
export PS1='\[\033[01;32m\]\@ \[\033[01;36m\]\W\[\033[01;32m\]$(git_branch)\[\033[00m\] '
2、ls命令终端上文件夹、文件等颜色显示
- dircolors 命令可以查看系统当前文件名称显示颜色的值
dircolors -p # 查看系统当前的文件名称显示的颜色配置
- 如何更改颜色配置
cd ~ dircolors -p > .dircolors # 将配置重定向到.dircolors文件中 vim ~/.dircolors # 修改.dirclors中的值 source ~/.bashrc
.dircolors文件中文件名含义 变量名 含义 NORMAL global default, although everything should be something FILE normal file DIR directory LINK symbolic link FIFO pipe SOCK socket BLK block device driver CHR character device driver ORPHAN orphaned syminks MISSING ... and the files they point to EXEC This is for files with execute permission
- 相关参数
字体样式 编码 效果 00 normal (no color、no bold) 01 Bold // 粗体 字体颜色 编码 效果 30 Black //黑色 31
Red //红色 32 Green //绿色 33 Yellow //黄色 34 Blue //蓝色 35 Magenta //洋红色 36 Cyan //蓝绿色 37 White //白色 背景颜色 编码 效果 40 Black //黑色 41 Red //红色 42 Green //绿色 43 Yellow //黄色 44 Blue //蓝色 45 Magenta //洋红色 46 Cyan //蓝绿色 47 White //白色
以上为个人喜好配置,可做调整!