用editor打開 ~/.bashrc 這支檔案,並看到這一段(約在56~60行)
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
1 2 3 4 5 | if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w[\033[00m\]\$ ' else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi |
這段是判斷有無開啟彩色Terminal顯示模式
第二行為預設的顯示設定,顯示的樣子大概像這樣
要顯示window number則改成下列內容
if [ "$color_prompt" = yes ]; then
if [ "$WINDOW" = "" ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;35m\][W$WINDOW]\[\033[00m\]\$ '
fi
else
1 2 3 4 5 6 7 | if [ "$color_prompt" = yes ]; then if [ "$WINDOW" = "" ]; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' else PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;35m\][W$WINDOW]\[\033[00m\]\$ ' fi else |
在彩色Terminal顯示模式裡面再加一個判斷screen是否啟用,沒有的話顯示預設樣式,有的話則顯示成有加入window number的樣式
簡單說明一下PS1修改的內容區分為兩部分
\[\033[01;35m\] 這段是宣告文字顏色(這裡用亮紫色當示範)
[W$WINDOW] 圖片中顯示[W6],$WINDOW這個變數是
修改儲存後下screen開新視窗後顯示的樣子就像這樣
完成收工!
[Ubuntu] 於指令列顯示screen的window number was last modified: 2017-02-06 by Calos