V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
hwdef
V2EX  ›  macOS

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

  •  
  •   hwdef · Aug 3, 2022 · 2737 views
    This topic created in 1365 days ago, the information mentioned may be changed or developed.

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

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

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


    我用这个来判断不同软件启用终端时用不同的主题
    pC0oc4EbCSsJUy4W
        6
    pC0oc4EbCSsJUy4W  
       Aug 4, 2022
    栗子🌰,自己加时间判断

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

    zinit light light
    else

    zinit light dark
    fi
    AlphaRobert
        7
    AlphaRobert  
       Aug 4, 2022   ❤️ 1
    系统自带的是因为使用的是 NSColor 那几个 dynamic semantic color ,像是 [NSColor textColor] 和 [NSColor textBackgroundColor] 之类的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1060 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 48ms · UTC 22:49 · PVG 06:49 · LAX 15:49 · JFK 18:49
    ♥ Do have faith in what you're doing.