How to output a different color for commands in a bash shell terminal?

I'm trying to figure out how to get various commands (such as touch , git , or echo to display a different color in the terminal. I installed the Dracula theme but the instance of it on my computer does not look the same, save for the background, text, and directory color. I have tried to install a few other themes where I have seen photos of command text displayed in a different color, but none of them work for some reason.

I'm on mac os sierra running the latest version of terminal. I also have have the display of ANSI colors enabled. I would really love to get this to work, as it would allow me to interpret my console more efficiently.


You can use tput command to assign color values to variables and use them in your output, like in below example:

GREEN=$(tput setaf 2)
RESET=$(tput sgr0)
echo ${GREEN}"HELLO WORLD"${RESET}

You can change the value of setaf for different colors

链接地址: http://www.djcxy.com/p/87982.html

上一篇: Silverlight / WPF以十六进制颜色设置椭圆

下一篇: 如何在bash shell终端输出不同颜色的命令?