How to color Linux terminal foreground and background text

非 Y 不嫁゛ 提交于 2019-12-11 03:56:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!