yung_terminal
yung_terminal

Reputation: 91

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.

Upvotes: 2

Views: 1562

Answers (1)

Lohit Gupta
Lohit Gupta

Reputation: 1081

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

Upvotes: 1

Related Questions