這裡介紹如何設定 xterm
虛擬終端機的配色,讓文字介面的命令列看起來也可以非常漂亮。
在 Linux 中若要讓命令列更好用,除了設定 xterm 的字型之外,佈景主題也是非常重要的一環,以下介紹 xterm
的終端機顏色設定方式。
xterm
預設的終端機顏色設定一般是寫在 /etc/X11/app-defaults/XTerm-color
這個設定檔中,如果要更改顏色,可以直接從這裡修改,而其顏色的設定方式就是指定每一個 ANSI 色碼所對應的實際顏色,8 種 ANSI 色碼加上亮色系的色碼,總共有 16 種顏色。
! These are the 8 ANSI colors and their bright equivalents. Depending on ! other resource settings, xterm may use the bright colors when displaying ! bold text (see the boldColors resource). *VT100*color0: black *VT100*color1: red3 *VT100*color2: green3 *VT100*color3: yellow3 *VT100*color4: blue2 *VT100*color5: magenta3 *VT100*color6: cyan3 *VT100*color7: gray90 *VT100*color8: gray50 *VT100*color9: red *VT100*color10: green *VT100*color11: yellow *VT100*color12: rgb:5c/5c/ff *VT100*color13: magenta *VT100*color14: cyan *VT100*color15: white
如果不想更動系統的設定檔,或是沒有權限修改,也可以從自己帳號的 ~/.Xresources
設定檔中加入顏色設定,設定方式跟 /etc/X11/app-defaults/XTerm-color
完全相同。
若要查看目前的設定,可以使用 appres
指令:
appres XTerm xterm | grep color
設定 16 種顏色的動作其實很繁瑣,建議可以從下面的佈景主題中挑選配好的顏色組合,既快速又方便。
這裡我蒐集了許多 xterm
的佈景主題配色,這些設定都可以直接複製到 /etc/X11/app-defaults/XTerm-color
或個人的 ~/.Xresources
中使用。
! Theme 01 *VT100*background: rgb:00/00/00 *VT100*foreground: rgb:a8/a8/a8 *VT100*color0: rgb:00/00/00 *VT100*color1: rgb:a8/00/00 *VT100*color2: rgb:00/a8/00 *VT100*color3: rgb:a8/54/00 *VT100*color4: rgb:00/00/a8 *VT100*color5: rgb:a8/00/a8 *VT100*color6: rgb:00/a8/a8 *VT100*color7: rgb:a8/a8/a8 *VT100*color8: rgb:54/50/54 *VT100*color9: rgb:f8/54/50 *VT100*color10: rgb:50/fc/50 *VT100*color11: rgb:f8/fc/50 *VT100*color12: rgb:50/54/f8 *VT100*color13: rgb:f8/54/f8 *VT100*color14: rgb:50/fc/f8 *VT100*color15: rgb:f8/fc/f8
! Theme 02 *VT100*background: rgb:00/00/00 *VT100*foreground: rgb:7f/7f/7f *VT100*color0: rgb:00/00/00 *VT100*color1: rgb:9e/18/28 *VT100*color2: rgb:ae/ce/92 *VT100*color3: rgb:96/8a/38 *VT100*color4: rgb:41/41/71 *VT100*color5: rgb:96/3c/59 *VT100*color6: rgb:41/81/79 *VT100*color7: rgb:be/be/be *VT100*color8: rgb:66/66/66 *VT100*color9: rgb:cf/61/71 *VT100*color10: rgb:c5/f7/79 *VT100*color11: rgb:ff/f7/96 *VT100*color12: rgb:41/86/be *VT100*color13: rgb:cf/9e/be *VT100*color14: rgb:71/be/be *VT100*color15: rgb:ff/ff/ff
! Theme 03 *VT100*background: rgb:00/00/00 *VT100*foreground: rgb:cf/cf/cf *VT100*color0: rgb:00/00/00 *VT100*color1: rgb:e0/10/10 *VT100*color2: rgb:20/ad/20 *VT100*color3: rgb:d4/c2/4f *VT100*color4: rgb:23/1b/b8 *VT100*color5: rgb:9c/38/85 *VT100*color6: rgb:1d/bd/b8 *VT100*color7: rgb:fe/fe/fe *VT100*color8: rgb:6a/6a/6a *VT100*color9: rgb:e8/3a/3d *VT100*color10: rgb:35/e9/56 *VT100*color11: rgb:ff/ff/2f *VT100*color12: rgb:3a/53/f0 *VT100*color13: rgb:e6/28/ba *VT100*color14: rgb:1c/f5/f5 *VT100*color15: rgb:ff/ff/ff
! Theme 04 *VT100*background: rgb:00/00/00 *VT100*foreground: rgb:ff/ff/ff *VT100*color0: rgb:00/00/00 *VT100*color1: rgb:d3/62/65 *VT100*color2: rgb:ae/ce/91 *VT100*color3: rgb:e7/e1/8c *VT100*color4: rgb:7a/7a/b0 *VT100*color5: rgb:96/3c/59 *VT100*color6: rgb:41/81/79 *VT100*color7: rgb:be/be/be *VT100*color8: rgb:66/66/66 *VT100*color9: rgb:ef/81/71 *VT100*color10: rgb:e5/f7/79 *VT100*color11: rgb:ff/f7/96 *VT100*color12: rgb:41/86/be *VT100*color13: rgb:ef/9e/be *VT100*color14: rgb:71/be/be *VT100*color15: rgb:ff/ff/ff
! Theme 05 *VT100*background: rgb:ad/aa/ad *VT100*foreground: rgb:00/00/00 *VT100*color0: rgb:00/00/00 *VT100*color1: rgb:64/0f/19 *VT100*color2: rgb:63/79/6b *VT100*color3: rgb:ad/71/42 *VT100*color4: rgb:4f/4f/89 *VT100*color5: rgb:b2/5c/7c *VT100*color6: rgb:52/75/6b *VT100*color7: rgb:ad/aa/ad *VT100*color8: rgb:52/55/52 *VT100*color9: rgb:a5/61/63 *VT100*color10: rgb:ce/c2/63 *VT100*color11: rgb:73/ae/70 *VT100*color12: rgb:36/70/9f *VT100*color13: rgb:aa/82/9c *VT100*color14: rgb:51/89/89 *VT100*color15: rgb:ff/ff/ef
! Theme 06 *VT100*background: rgb:be/be/be *VT100*foreground: rgb:21/21/21 *VT100*color0: rgb:00/00/00 *VT100*color1: rgb:bf/72/76 *VT100*color2: rgb:86/af/80 *VT100*color3: rgb:96/8a/38 *VT100*color4: rgb:36/73/b5 *VT100*color5: rgb:9a/70/b2 *VT100*color6: rgb:7a/be/cc *VT100*color7: rgb:db/db/db *VT100*color8: rgb:66/92/af *VT100*color9: rgb:e5/50/5f *VT100*color10: rgb:87/bc/87 *VT100*color11: rgb:e0/d9/5c *VT100*color12: rgb:1b/85/d6 *VT100*color13: rgb:ad/73/ba *VT100*color14: rgb:33/8e/aa *VT100*color15: rgb:f4/f4/f4
! Theme 07 *VT100*background: rgb:67/67/67 *VT100*foreground: rgb:ff/ff/ff *VT100*color0: rgb:00/00/00 *VT100*color1: rgb:bf/46/46 *VT100*color2: rgb:67/b2/5f *VT100*color3: rgb:cf/c4/4e *VT100*color4: rgb:51/60/83 *VT100*color5: rgb:ca/6e/ff *VT100*color6: rgb:92/b2/f8 *VT100*color7: rgb:d5/d5/d5 *VT100*color8: rgb:00/00/00 *VT100*color9: rgb:f4/8a/8a *VT100*color10: rgb:a5/d7/9f *VT100*color11: rgb:e1/da/84 *VT100*color12: rgb:a2/bb/ff *VT100*color13: rgb:e2/b0/ff *VT100*color14: rgb:ba/cd/f8 *VT100*color15: rgb:d5/d5/d5
! Theme 08 *VT100*background: rgb:10/10/10 *VT100*foreground: rgb:d3/d3/d3 *VT100*color0: rgb:10/10/10 *VT100*color1: rgb:cd/5c/5c *VT100*color2: rgb:2e/8b/57 *VT100*color3: rgb:f0/e6/8c *VT100*color4: rgb:b0/c4/de *VT100*color5: rgb:ba/55/d3 *VT100*color6: rgb:46/82/b4 *VT100*color7: rgb:d3/d3/d3 *VT100*color8: rgb:4d/4d/4d *VT100*color9: rgb:ff/6a/6a *VT100*color10: rgb:8f/bc/8f *VT100*color11: rgb:ff/fa/cd *VT100*color12: rgb:1e/90/ff *VT100*color13: rgb:db/70/93 *VT100*color14: rgb:5f/9e/a0 *VT100*color15: rgb:ff/ff/ff