Claudeと作業をしていると、カラーコードを提示してくることがある。しかし、WezTermにはカラーコードをプレビューする機能はないので、何色なのか分からないという困りがあった。Claudeと相談して便利グッズを作ったのでメモしておく。
この設定をreturn configよりも前に追記すると、右上のステータスバーに色見本が出力されるようになる。

インラインでのプレビューは無理そうだったので諦めたけど、実用上はこれで十分。
-- 表示中の画面から #rrggbb / #rgb を拾い、右上のステータスバーに色見本を自動表示する local COLOR_SWATCH_MAX = 8 wezterm.on('update-status', function(window, pane) local text = pane:get_lines_as_text() local seen, items = {}, {} for hex in text:gmatch('#(%x%x%x%x%x%x)%f[^%w]') do hex = hex:lower() if not seen[hex] then seen[hex] = true table.insert(items, hex) end end for hex in text:gmatch('#(%x%x%x)%f[^%w]') do local full = hex:lower():gsub('(.)', '%1%1') if not seen[full] then seen[full] = true table.insert(items, full) end end local parts = {} for i, hex in ipairs(items) do if i > COLOR_SWATCH_MAX then break end table.insert(parts, { Background = { Color = '#' .. hex } }) table.insert(parts, { Text = ' ' }) table.insert(parts, 'ResetAttributes') table.insert(parts, { Text = ' #' .. hex .. ' ' }) end window:set_right_status(wezterm.format(parts)) end)