FreeBSD/cshrc如何設定 prompt 的顏色

來源:互聯網
上載者:User

先上個例子:

set prompt="%{\e[32;1m%}%n%{\e[37m%}@%{\e[33m%}%m%{\e[37m%}:%{\e[36m%}%~%{\e[37m%}"\$"%{\e[0m%} "
set prompt="%{\e[31;1m%}root%{\e[37m%}@%{\e[33m%}%m%{\e[37m%}:%{\e[36m%}%/%{\e[37m%}#%{\e[0m%} "

 %{ ... %}  代表顏色等設定的開始結束,中間不能有空格

 \e[ ... m  定義顏色或者字型粗細, \e  轉義 [  ,這個是必須的(感覺和 \033 是相等的), m 為結束標誌。

如果你想同時設定顏色和背景,只需用逗號將他們分隔開即可,其中 1 代表的是粗體。將顏色設定為 0 ,可恢複預設。

各顏色值請參閱本表:

例如,你想設定一個粗體、青色、紅背景的Hello World可以這麼做:

 %{\e[36;41;1m%}Hello World%{\e[0m%} 

參考文章:

  • How to color a prompt on FreeBSD/cshrc?
  • How to make custom prompts.
  • Shell configuration file .cshrc.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.