歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 如何修改Ubuntu終端用戶名顏色修改為紅色

如何修改Ubuntu終端用戶名顏色修改為紅色

日期:2017/2/28 13:58:55   编辑:Linux教程

Linux操作系統:Ubuntu 14.04

由於輸入特定符號會導致亂碼,亂碼部分用.............顯示,有些截圖顯示!!!!!!!!

整個操作代碼流程圖片和最終顯示結果

輸入>echo $PS1

顯示:如上圖

在個人用戶文件夾輸入

輸入gedit ~/.bashrc

修改這幾行代碼

if [ "$color_prompt" = yes ]; then

PS1=....

else

PS1==...

fi

unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir

重改為:

# if [ "$color_prompt" = yes ]; then

#PS1='$..........\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

# else

# PS1='$........................\u@\h:\w\$ '

# fi

unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir

然後再文件的末尾一行加上:

(下一行是截圖)PS1='$...................\033[01;31m\]\u\[\033[00m\]@\h:\w\$ '

保存後退出,然後source一下,也就是輸入>source ~/.bashrc

在root文件夾裡面位置 /root也同樣操作一遍。

以上是我個人的修改。

以下是網上的參考:(再下面是截圖)

customer: PS1='$........................\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

root: PS1='$........................\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

更多Ubuntu相關信息見Ubuntu 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=2

Copyright © Linux教程網 All Rights Reserved