diff --git a/lua/image/backends/sixel.lua b/lua/image/backends/sixel.lua index ac61f77..002b175 100644 --- a/lua/image/backends/sixel.lua +++ b/lua/image/backends/sixel.lua @@ -129,9 +129,7 @@ local send_sixel = function(sixel_data, x, y) if not has_st_end then wrapped_data = wrapped_data .. "\27\\" end -- tmux passthrough: wrap DCS sequence so tmux forwards it to the terminal - if utils.tmux.is_tmux then - wrapped_data = utils.tmux.escape(wrapped_data) - end + if utils.tmux.is_tmux and not utils.tmux.has_native_sixel then wrapped_data = utils.tmux.escape(wrapped_data) end -- build sequence local sequence = "" @@ -259,7 +257,7 @@ function backend.setup(state) end -- tmux check - if utils.tmux.is_tmux and not utils.tmux.has_passthrough then + if utils.tmux.is_tmux and not utils.tmux.has_native_sixel and not utils.tmux.has_passthrough then log.warn("tmux detected but passthrough may not be enabled for sixel") end diff --git a/lua/image/utils/tmux.lua b/lua/image/utils/tmux.lua index d0df7e9..156c608 100644 --- a/lua/image/utils/tmux.lua +++ b/lua/image/utils/tmux.lua @@ -4,9 +4,14 @@ local pane_position = nil local pane_position_clear_scheduled = false local has_passthrough = false +local has_native_sixel = false if is_tmux then local ok, result = pcall(vim.fn.system, { "tmux", "show", "-Apv", "allow-passthrough" }) if ok and (result:sub(-3) == "on\n" or result:sub(-4) == "all\n") then has_passthrough = true end + local features_ok, features = pcall(vim.fn.system, { "tmux", "display-message", "-p", "#{client_termfeatures}" }) + if features_ok and vim.v.shell_error == 0 then + has_native_sixel = ("," .. vim.trim(features) .. ","):find(",sixel,", 1, true) ~= nil + end end local create_dm_getter = function(name) @@ -91,6 +96,7 @@ end return { is_tmux = is_tmux, + has_native_sixel = has_native_sixel, has_passthrough = has_passthrough, get_pid = create_dm_getter("pid"), get_socket_path = create_dm_getter("socket_path"),