xterm 配置: 一行命令搞定,开箱即用,和vscode终端效果一样

Published on
Authors
  • avatar
    Name
    套路猿
    Twitter

xterm 广泛运用于各种Linux操作系统。它轻量、快捷、可高度定制,非常适合需要高效终端体验的用户

不过它自带的效果不够好看,本配置文件提供 简洁清爽的色彩效果,和vscode终端效果一样 ,懒人配置,开箱即用

xterm 配置文件详解

以下是完整的.xresources配置文件:

! XTerm resources
!
! Remember to run `xrdb < .Xresources` after changing anything.
!
! Tavis Ormandy <taviso@gmail.com>

! Set the default UI font (menus, toolbar, etc)
XTerm*XftFont:                  Segoe UI:size=10:antialias=true:style=Regular

! Color of UI Components
XTerm*.SimpleMenu.background:   #ffffff
XTerm*.SimpleMenu.foreground:   #000000

! Tone down the Xaw3D effect.
XTerm*shapeStyle:               Rectangle
XTerm*beNiceToColormap:         false
XTerm*relief:                   None
XTerm*highlightThickness:       0

! Dont automatically jump to the bottom on output, but do on keypress.
XTerm*scrollTtyOutput:          false
XTerm*scrollKey:                true
XTerm*scrollBar:                false
XTerm*eightBitInput:            false
XTerm*cursorBlink:              true

! Dont allow mouse ops - it can be enabled in the view Menu at runtime.
! The reason is it breaks copy/paste if an application requests mouse events,
! because the application gets the event instead of XTerm.
XTerm*allowMouseOps:            false

! Dont change my title by default, this can be re-enabled from the menu.
XTerm*allowTitleOps:            false
XTerm*allowFontOps:             false

! Mouse cursor configuration, I prefer to keep it simple.
XTerm*pointerColor:             white
XTerm*pointerColorBackground:   black
XTerm*pointerShape:             left_ptr

! Only select text, not empty space around it.
XTerm*highlightSelection:       true

! The distance between the edge of the screen and the characters.
XTerm*vt100.internalBorder:     6

! The border around elements.
XTerm*.BorderColor:             #ffffff
XTerm*vt100.BorderColor:        #d0d0d0
XTerm*BorderWidth:              3

! Menu Names, I dont like the default verbose names.
XTerm*.mainMenu.label:          File
XTerm*.vtMenu.label:            Options
XTerm*.fontMenu.label:          View

! You can rename menu entries, like this, I dont know why the menubar
! is called a "toolbar", probably historical reasons.
XTerm*.mainMenu.toolbar.label:  Menubar

! Adjust how the active menu item looks
XTerm*.SimpleMenu.*.shadowWidth: 3
XTerm*.SimpleMenu.*.topShadowPixel: SkyBlue
XTerm*.SimpleMenu.*.bottomShadowPixel: LightSkyBlue

! Try to hide the useless title displayed at the top of menus, I know what
! menu it is because I just clicked it.
XTerm*.*.menuLabel.vertSpace:   0
XTerm*.*.menuLabel.foreground:  #ffffff
XTerm*.*.menuLabel.XftFont:     Courier:size=0

! Space around menu entries.
XTerm*.SimpleMenu.*.topMargin:  0
XTerm*.SimpleMenu.*.bottomMargin: 0
XTerm*.SimpleMenu.*.leftMargin: 32
XTerm*.SimpleMenu.*.rightMargin: 64
! The height of each menu entry, the default calculates it from font size.
! XTerm*.SimpleMenu.*.rowHeight: 16

! Space around the checkmark in the menus.
XTerm*.SimpleMenu.*.leftWhitespace: 16
!XTerm*.SimpleMenu.*.rightWhitespace: 8

! Trim vertical padding around the toolbar, all elements have a form.
XTerm*Form.menubar.vSpace:      0
XTerm*Form.menubar.vertDistance: 0
!XTerm*Form.menubar.foreground: #000000
!XTerm*Form.menubar.background: #ffffff
!XTerm*Form.menubar.Thickness:  0

! Fonts
XTerm*vt100.faceName:           xft:Consolas:size=10:antialias=true:style=Regular
XTerm*vt100.boldFont:           xft:Consolas:size=10:antialias=true:style=Bold

! Size and Title
XTerm*vt100.geometry:           100x30
XTerm*title:                    Terminal
XTerm*iconHint:                 /home/taviso/.icons/computer_x11.xpm

! Terminal Colors
XTerm*vt100.background:     #1E1E1E
XTerm*vt100.foreground:     #D4D4D4
XTerm*cursorColor:          #FFFFFF

! I like bold items to be in bright white.
XTerm*veryBoldColors:       4
XTerm*colorBDMode:          true
XTerm*colorBD:              #ffffff
XTerm*colorRV:              #ffffff

! I can see a small line between box characters, this fixes it.
XTerm*forceBoxChars:        true
XTerm*vt100.scaleHeight:    1.04

! This (or similar id) is required for Sixel support.
XTerm*decTerminalID:        vt382

! Color Scheme
! 0-7:  Black, Red, Green, Yellow, Blue, Purple, Cyan, White
! 8-15: Bright Black, Bright Red, ...
XTerm*color0:               #000000
XTerm*color8:               #808080
XTerm*color1:               #CD3131
XTerm*color9:               #F14C4C
XTerm*color2:               #0DBC79
XTerm*color10:              #23D18B
XTerm*color3:               #CDCD00
XTerm*color11:              #FFFF00
XTerm*color4:               #2472C8
XTerm*color12:              #3B8EEA
XTerm*color5:               #BC3FBC
XTerm*color13:              #D670D6
XTerm*color6:               #11A8CD
XTerm*color14:              #29B8DB
XTerm*color7:               #E5E5E5
XTerm*color15:              #FFFFFF

!  XTerm Translations, i.e. keyboard remapping.
!
! Notes:
!   ~       means that that modifier must not be asserted.
!   !       means that the listed modifiers must be in the correct state and
!               no other modifiers can be asserted.
!   None    means no modifiers can be asserted.
!   :       directs the Intrinsics to apply any standard modifiers in the event.
!   ^       is an abbreviation for the Control modifier.
!   $       is an abbreviation for Meta
!
! Example:
!   No modifiers:                          None <event> detail
!   Any modifiers:                              <event> detail
!   Only these modifiers:           ! mod1 mod2 <event> detail
!   These modifiers and any others:   mod1 mod2 <event> detail

! Below:
!
! - I have some old apps that use Alt-F4, but thats sometimes difficult to
!       press so Ctrl-Shift-F4 does the same thing.
! - Ctrl-MouseWheel can be used to increase and descrease font size.
! - Ctrl-I is totally useless, because it is literally impossible for
!       applications to differentiate it from Tab. You can remap it to some
!       other harder-to-press keybinding here, I use it for Italics in
!       wordperfect.

XTerm*vt100.translations:   #override           \n\
    Ctrl Shift <Key>F4:     string("\033[1;3S") \n\
  ! Ctrl <Btn4Up>:          larger-vt-font()    \n\
  ! Ctrl <Btn5Up>:          smaller-vt-font()   \n\
    ^<Key>I:                string("\014")      \n\

xterm 如何重新加载配置文件

在终端中输入以下命令以重新加载.xresources配置文件:

xrdb  ~/.Xresources

这将会使配置文件中的所有更改都立即生效,关闭终端重新打开即可看到效果.