深入探索Bash配置与自定义
1. ANSI颜色设置
在ANSI标准中,颜色和属性通过特定的代码来表示。例如,1;34m表示“将字符属性设置为亮色,字符颜色设置为蓝色”,0m表示“清除所有属性并取消颜色设置”。以下是一个展示所有可能颜色组合的脚本:
#!/usr/bin/env bash # cookbook filename: colors # # Daniel Crisman's ANSI color chart script from # The Bash Prompt HOWTO: 6.1. Colours # http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html. # # This file echoes a bunch of color codes to the # terminal to demonstrate what's available. Each # line is the color code of one foreground color, # out of 17 (default + 16 escapes), followed by a # test use of that color on all nine background # colors (default + 8 escapes). # T='gYw' # The test text echo -e "\n 40m 41m 42m 43m\ 44m