Skip to content

Conversation

@tecosaur
Copy link
Member

@tecosaur tecosaur commented Oct 26, 2025

Wouldn't it be nice if Julia/the REPL knew what your terminal colours were, and displayed content appropriately?

useful description coming soon-ish

Sneak peek:

image

Query durations

  • initial query on a local machine: ~0.1s (which I suspect is due to other work that gets scheduled before the response is read)
  • subsequent queries on a local machine: <0.01s
  • initial query over SSH (100ms latency): ~0.3s

Important

This is asynchronous, and does not impact startup latency

Tested terminals

Test script
using StyledStrings
let (; FACES, SimpleColor, rgbcolor) = StyledStrings  # Grab some private API
    colors = Iterators.flatten((c, Symbol("bright_" * String(c))) for c in
        [:black, :green, :cyan, :blue, :magenta, :red, :yellow, :white])
    println(styled"{bold:    Swatch test  Read  Actual}\n ", ''^30)
    termfg, termbg = @. SimpleColor(rgbcolor((:foreground, :background)))
    println(styled"     foreground  {(bg=$termfg):  }    {inverse:  }")
    println(styled"     background {light,grey:▕{(bg=$termbg):  }▏  ▕{:  }▏}")
    for color in colors
        termc = SimpleColor(FACES.basecolors[color])
        println(styled" $(lpad(color, 14))  {(bg=$termc):  }    {(bg=$color):  }")
    end
    print(styled"\n {bold:Platform:} {emphasis:$(Sys.KERNEL){grey:/}$(ENV[\"TERM\"])} {grey:(truecolor }")
    println(if Base.ttyhastruecolor() styled"{green,bold:✓}" else styled"{red,bold:✕}" end, styled"{grey:)}")
    println(styled" Do the swatches match?")
end

Everything works

  • Linux
    • Kitty
    • Wezterm
    • Foot
    • Ghostty
    • Xterm
    • Alacritty
    • St (Suckless)
    • Ubuntu terminal (Gnome terminal?)
    • Tilix
  • Mac
    • Terminal.app
    • iTerm2
    • WezTerm
    • Alacritty
    • Ghostty
    • Kitty
  • Windows
    • Windows terminal (it messes up inverse video though)
    • Windows terminal: WSL

Misbehaving (terminal's fault)

  • Linux
    • Konsole (lies about values)
  • Emacs
    • Eat (doesn't supply colours)
    • Vterm (doesn't report anything)
  • Mac
    • iTerm2 + Tmux (doesn't report anything)
  • Windows
    • Wezterm via Ubuntu WSL (doesn't report anything)

Misbehaving (our fault)

  • Nothing yet 🙂

This is not ready for review yet, I just want CI to build it so that helpful testers on Zulip (:wave:) can try this with juliaup add +pr59958.

@tecosaur tecosaur added REPL Julia's REPL (Read Eval Print Loop) display and printing Aesthetics and correctness of printed representations of objects. labels Oct 26, 2025
@tecosaur tecosaur force-pushed the term-recolour branch 3 times, most recently from 5633335 to 7e22584 Compare October 27, 2025 15:29
@tecosaur tecosaur force-pushed the term-recolour branch 2 times, most recently from 5532468 to 80b448e Compare October 29, 2025 19:11
@topolarity
Copy link
Member

iTerm2 + Tmux (doesn't report anything)

Any issue that we can file upstream? This is a fairly common configuration, esp. since iTerm2 has tmux integration

@tecosaur
Copy link
Member Author

tecosaur commented Oct 31, 2025

Any issue that we can file upstream? This is a fairly common configuration, esp. since iTerm2 has tmux integration

Potentially, there seem to be a few closed OSC-related issues on tmux's repo. I'm also not 100% on the performance: it might be passing through fg/bg info, in which case as of some recent (unpushed) improvements we will still be able to set pick light/dark appropriately and set fg/bg colours.

Testing tmux locally myself, I see that it does pass through OSC 10 and OSC 11 codes (these are the fg/bg codes):

~$ printf '\e]10;?\e\\'
10;rgb:bbbb/c2c2/cfcf

~$ printf '\e]11;?\e\\'
11;rgb:2424/2727/3030

~$ printf '\e]4;1;?\e\\'

~$

@tecosaur
Copy link
Member Author

tecosaur commented Nov 2, 2025

I'm not sure what's a good idea to do here in terms of unit testing, since this should be tested against a collection of different terminal emulators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

display and printing Aesthetics and correctness of printed representations of objects. REPL Julia's REPL (Read Eval Print Loop)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants