[英]How to display text at the bottom of the terminal window, and make it stay there, in Bash?
[英]How to make Macbook Terminal text less transparent
使用轉義碼設置PS1變量很繁瑣,而且經常會有副作用。 多年來,我一直是這樣做的,而且換行經常被打斷。 我在終端窗口中測試了您的PS1。 似乎隨着顏色滲入下一行,某些東西未正確終止。 我使用tput設置PS1,這使分配更具可讀性。 這是我在.bash_profile中的內容:
set_prompt() {
local red=$(tput setaf 1)
local green=$(tput setaf 2)
local yellow=$(tput setaf 3)
local blue=$(tput setaf 4)
local magenta=$(tput setaf 5)
local cyan=$(tput setaf 6)
local white=$(tput setaf 7)
local reset=$(tput sgr0)
if [ ${UID} -eq 0 ]; then
# user is red when we are root
export PS1="\[$red\]\u\[$white\]@\[$green\]\h\[$white\]:\[$yellow\]\w [$reset\]$ "
else
export PS1="\[$blue\]\u\[$white\]@\[$green\]\h\[$white\]:\[$yellow\]\w\[$reset\]$ "
fi;
}
# Don't set the prompt for dumb terminals
if [ ${TERM+x} -a "${TERM-}" != "dumb" ]; then
set_prompt
fi
較亮的文本來自此塊,它設置了粗體屬性1
:
\[\033[1;33m\]
文本變暗,因為您在末尾省略了粗體:
\[\033[0;32m\]
32
和33
選擇綠色和黃色 ,但沒有粗體屬性,大多數終端將其顯示為棕色 。
進一步閱讀
我也使用Macbook,但不使用默認的終端應用程序。 我使用iTerm,它確實更加靈活,可以根據您希望它顯示事物的方式進行配置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.