皮肤

概述

您可以根据自己的审美和风格来设计 K9s 的样式。皮肤是 YAML 文件,能让用户更改 K9s 的表示层。皮肤文件位于 $XDG_CONFIG_HOME/k9s/skins 文件夹中。您可以使用 skin: skin_file_name_no_extension 属性指定一个适用于所有集群的通用皮肤。此外,您也可以在特定上下文的配置块中定义相同的 skin 属性,为单个上下文设置皮肤。最后,您还可以通过在 shell 中设置环境变量 K9S_SKIN 来完全覆盖这些设置,例如 export K9S_SKIN="dracula"

如果您的集群存在对应的皮肤文件,那么该皮肤将被加载,否则将继续使用默认皮肤。因此,如果您想为每个上下文设置不同的 K9s 外观,假设您的集群名为 clusterX,上下文为 contextY,那么您的皮肤属性应该写成 skin: blee。这里的 blee 指向 $XDG_CONFIG_HOME/k9s/skins/blee.yaml 这个皮肤文件。以下是一个皮肤文件示例,更多皮肤可以在 K9s 代码库的 skins 目录中找到。

颜色可以通过命名颜色(见下表)或使用十六进制表示法来定义。为了保留您终端会话的背景色,我们添加了一个名为 default 的颜色,用于在需要时表示透明背景色。


K9s Dracula 皮肤


随着更多功能的添加,皮肤文件的布局可能会发生变化,请谨慎操作!


皮肤配置

# $XDG_CONFIG_HOME/k9s/config.yaml
# Global skin is specified
k9s:
  liveViewAutoRefresh: false
  refreshRate: 2
  maxConnRetry: 5
  readOnly: false
  ui:
    enableMouse: false
    headless: false
    logoless: false
    crumbsless: false
    noIcons: false
    # Toggles reactive UI. This option provide for watching on disk artifacts changes and update the UI live  Defaults to false.
    reactive: false
    # Uses in_the_navy skin located in your $XDG_CONFIG_HOME/skins/in_the_navy.yaml
    skin: in_the_navy # => All clusters will use this skin unless otherwise specified in the context configuration file
  ...


皮肤示例

# $XDG_CONFIG_HOME/k9s/in_the_navy_skin.yaml
k9s:
  # General K9s styles
  body:
    fgColor: dodgerblue
    bgColor: '#ffffff'
    logoColor: '#0000ff'

  # ClusterInfoView styles
  info:
    fgColor: lightskyblue
    sectionColor: steelblue

  # Frame styles
  frame:
    # Borders styles
    border:
      fgColor: dodgerblue
      focusColor: aliceblue

    # MenuView attributes and styles
    menu:
      fgColor: darkblue
      keyColor: cornflowerblue
      # Used for favorite namespaces
      numKeyColor: cadetblue

    # CrumbView attributes for history navigation.
    crumbs:
      fgColor: white
      bgColor: steelblue
      activeColor: skyblue

    # Resource status and update styles
    status:
      newColor: '#00ff00'
      modifyColor: powderblue
      addColor: lightskyblue
      errorColor: indianred
      highlightcolor: royalblue
      killColor: slategray
      completedColor: gray

    # Border title styles.
    title:
      fgColor: aqua
      bgColor: white
      highlightColor: skyblue
      counterColor: slateblue
      filterColor: slategray
  # Specific views styles
  views:
    # TableView attributes.
    table:
      fgColor: blue
      bgColor: darkblue
      cursorColor: aqua
      # Header row styles.
      header:
        fgColor: white
        bgColor: darkblue
        sorterColor: orange

    # YAML info styles.
    yaml:
      keyColor: steelblue
      colonColor: blue
      valueColor: royalblue

    # Logs styles.
    logs:
      fgColor: white
      bgColor: black



命名颜色参考

black (黑色) maroon (褐红色) green (绿色) olive (橄榄色) navy (海军蓝)
purple (紫色) teal (青色) silver (银色) gray (灰色) red (红色)
lime (亮绿色) yellow (黄色) blue (蓝色) fuchsia (紫红色) aqua (浅绿色)
white (白色) aliceblue (爱丽丝蓝) antiquewhite (古董白) aquamarine (海蓝色) azure (蔚蓝色)
beige (米色) bisque (橘黄色) blanchedalmond (杏仁白) blueviolet (蓝紫色) brown (棕色)
burlywood (原木色) cadetblue (军服蓝) chartreuse (黄绿色) chocolate (巧克力色) coral (珊瑚色)
cornflowerblue (矢车菊蓝) cornsilk (玉米丝色) crimson (深红色) darkblue (深蓝色) darkcyan (深青色)
darkgoldenrod (深金黄色) darkgray (深灰色) darkgreen (深绿色) darkkhaki (深卡其色) darkmagenta (深洋红色)
darkolivegreen (深橄榄绿) darkorange (深橙色) darkorchid (深兰花紫) darkred (深红色) darksalmon (深肉色)
darkseagreen (深海绿色) darkslateblue (深石板蓝) darkslategray (深石板灰) darkturquoise (深绿松石色) darkviolet (深紫罗兰色)
deeppink (深粉色) deepskyblue (深天蓝色) dimgray (暗灰色) dodgerblue (道奇蓝) firebrick (砖红色)
floralwhite (花白色) forestgreen (森林绿) gainsboro (淡灰色) ghostwhite (幽灵白) gold (金色)
goldenrod (金黄色) greenyellow (黄绿色) honeydew (蜜瓜色) hotpink (亮粉色) indianred (印度红)
indigo (靛蓝色) ivory (象牙色) khaki (卡其色) lavender (薰衣草紫) lavenderblush (淡紫红)
lawngreen (草绿色) lemonchiffon (柠檬绸色) lightblue (浅蓝色) lightcoral (浅珊瑚色) lightcyan (浅青色)
lightgoldenrodyellow (浅金黄色) lightgray (浅灰色) lightgreen (浅绿色) lightpink (浅粉色) lightsalmon (浅肉色)
lightseagreen (浅海绿色) lightskyblue (浅天蓝色) lightslategray (浅石板灰) lightsteelblue (浅钢蓝色) lightyellow (浅黄色)
limegreen (酸橙绿) linen (亚麻色) mediumaquamarine (中海蓝色) mediumblue (中蓝色) mediumorchid (中兰花紫)
mediumpurple (中紫色) mediumseagreen (中海绿色) mediumslateblue (中石板蓝) mediumspringgreen (中春绿色) mediumturquoise (中绿松石色)
mediumvioletred (中紫罗兰红) midnightblue (午夜蓝) mintcream (薄荷奶油色) mistyrose (薄雾玫瑰色) moccasin (鹿皮色)
navajowhite (纳瓦霍白) oldlace (旧蕾丝色) olivedrab (橄榄褐) orange (橙色) orangered (橙红色)
orchid (兰花紫) palegoldenrod (淡金黄色) palegreen (淡绿色) paleturquoise (淡绿松石色) palevioletred (淡紫罗兰红)
papayawhip (番木瓜色) peachpuff (桃肉色) peru (秘鲁色) pink (粉色) plum (李子色)
powderblue (粉蓝色) rebeccapurple (利百加紫) rosybrown (玫瑰棕色) royalblue (宝蓝色) saddlebrown (马鞍棕色)
salmon (肉色) sandybrown (沙棕色) seagreen (海绿色) seashell (贝壳色) sienna (赭色)
skyblue (天蓝色) slateblue (石板蓝) slategray (石板灰) snow (雪白色) springgreen (春绿色)
steelblue (钢蓝色) tan (棕褐色) thistle (蓟色) tomato (番茄色) turquoise (绿松石色)
violet (紫罗兰色) wheat (小麦色) whitesmoke (白烟色) yellowgreen (黄绿色) grey (灰色)
dimgrey (暗灰色) darkgrey (深灰色) darkslategrey (深石板灰) lightgrey (浅灰色) lightslategrey (浅石板灰)
slategrey (石板灰)        

 返回



© 2025 Imhotep Software LLC. 所有材料均根据 Apache v2.0 许可。