V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
hwdef
V2EX  ›  macOS

macos 自带的终端如何自动切换主题?

  •  
  •   hwdef · 2022-08-03 16:29:17 +08:00 · 1575 次点击
    这是一个创建于 603 天前的主题,其中的信息可能已经有所发展或是发生改变。

    macos 自带终端里的Basic主题可以根据系统的浅色或者深色自动切换,但是换成其他主题就不行了。有什么办法可以让终端的配色根据系统的配色自动切换吗?

    7 条回复    2022-08-04 16:37:00 +08:00
    EvilDevilJin
        1
    EvilDevilJin  
       2022-08-03 16:48:21 +08:00
    换 iTem2 吧.
    主题配色,虽然自带终端也能用。
    https://github.com/mbadolato/iTerm2-Color-Schemes

    搭配自动切换深浅色主题插件。
    https://iterm2.com/python-api/examples/theme.html
    bao3
        2
    bao3  
       2022-08-03 16:52:46 +08:00
    前几年我也热爱折腾主题 /Theme ,现在,就默认的就挺好用了。
    hwdef
        3
    hwdef  
    OP
       2022-08-03 17:14:34 +08:00
    @bao3
    这不是折腾,,,我只是想让终端颜色根据系统主题色自动变,,否则晚上会被白色背景闪到
    xtinput
        4
    xtinput  
       2022-08-03 20:17:32 +08:00
    系统都一直是浅色主题,深色主题用不习惯
    fatelight
        5
    fatelight  
       2022-08-04 01:29:35 +08:00   ❤️ 1
    用 zsh 等
    给一个思路,自动切换配置
    配置文件中 判断时间,判断终端类型
    然后加载当前指定主题


    我用这个来判断不同软件启用终端时用不同的主题
    fatelight
        6
    fatelight  
       2022-08-04 01:31:17 +08:00
    栗子🌰,自己加时间判断

    if [ "$TERM_PROGRAM" = iTerm.app ]; then

    zinit light light
    else

    zinit light dark
    fi
    AlphaRobert
        7
    AlphaRobert  
       2022-08-04 16:37:00 +08:00   ❤️ 1
    系统自带的是因为使用的是 NSColor 那几个 dynamic semantic color ,像是 [NSColor textColor] 和 [NSColor textBackgroundColor] 之类的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2425 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 16:07 · PVG 00:07 · LAX 09:07 · JFK 12:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.