问题
I am working on a Linux terminal. The terminal foreground and background colors are hard to look at.
Is there a way to change the terminal prompt colors and keep the commands (ls) at the same colors?
回答1:
How to color the command prompt in the terminal in Linux. This will give you a colored command line and everything else is one color.
$ export PS1='\[\033[00;35m\]\u\[\033[00m\]@\[\033[00;35m\]\H\[\033[00m\]:\[\033[00;33m\]\W\[\033[00m\] \$\[\033[00;34m '
If you want to make this change permanent, add the command to your /home/yourusername/.bashrc
file.
回答2:
You could use ANSI escape codes in your program output. And if you are coding the terminal emulator, you should make it understand those ANSI escape codes.
来源:https://stackoverflow.com/questions/17177174/how-to-color-linux-terminal-foreground-and-background-text