From 21ec8c60d2df3d59aded9e5fb78a0a22c9dec86a Mon Sep 17 00:00:00 2001 From: Zacharias-Brohn Date: Tue, 16 Dec 2025 22:10:06 +0100 Subject: [PATCH] powerline? --- lua/zterm-navigator/init.lua | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/lua/zterm-navigator/init.lua b/lua/zterm-navigator/init.lua index 15692cb..1e29307 100644 --- a/lua/zterm-navigator/init.lua +++ b/lua/zterm-navigator/init.lua @@ -35,28 +35,30 @@ M.config = { }, } --- Create a persistent TTY handle for writing escape sequences directly to the terminal. --- This bypasses neovim's terminal handling by using libuv to write to stdout. -local tty_handle = nil +-- Send raw escape sequence to the terminal, bypassing neovim's terminal handling. +-- We use vim.loop (libuv) to open /dev/tty directly, which gives us a direct +-- connection to the controlling terminal, bypassing neovim's I/O handling. +local tty_fd = nil -local function get_tty_handle() - if tty_handle then - return tty_handle +local function get_tty_fd() + if tty_fd then + return tty_fd end - -- Create a TTY handle wrapping stdout (fd 1) - -- The second parameter (true) means readable=false (write-only) - local handle = vim.loop.new_tty(1, false) - if handle then - tty_handle = handle + -- Open /dev/tty directly using libuv's fs_open + local fd, err = vim.loop.fs_open("/dev/tty", "w", 438) -- 438 = 0666 octal + if fd then + tty_fd = fd + else + vim.notify("zterm-navigator: failed to open /dev/tty: " .. (err or "unknown"), vim.log.levels.WARN) end - return tty_handle + return tty_fd end --- Send raw escape sequence to the terminal, bypassing neovim's terminal handling +-- Send raw escape sequence to the terminal local function send_to_tty(str) - local handle = get_tty_handle() - if handle then - handle:write(str) + local fd = get_tty_fd() + if fd then + vim.loop.fs_write(fd, str) end end