Get currently typed text #1553
Replies: 2 comments 1 reply
-
If you're using shell integration, your shell can markup the output using That information is exposed via the underlying Lines 359 to 362 in 4b457da a zone has the following definition: Lines 120 to 127 in 4b457da If that was exposed to lua, then you could find the zone that intersects with the cursor position and then you would know which portions of which lines to inspect. Exposing the method to lua may be as simple as copying and adapting one of these, but referencing wezterm/wezterm-gui/src/scripting/pane.rs Lines 48 to 50 in 4b457da |
Beta Was this translation helpful? Give feedback.
-
I was trying to do the same thing. I use the I ended up with a hacky prompt-based approach, just sharing here in case it's better than nothing for someone. {
key = 'Y',
mods = 'CTRL|SHIFT',
action = wezterm.action_callback(function(window, pane)
local text = pane:get_lines_as_text(1)
text = string.gsub(text, "✦ ❯ ", "")
window:copy_to_clipboard(text, "Clipboard")
end),
}, |
Beta Was this translation helpful? Give feedback.
-
Is there a way to get the currently entered command, probably between the prompt and the cursor? This is the closest I have come so far:
In the above, the last element in
lines
is the "current" line. I could take that last line, split on what I happen to know my prompt is, and take everything after the split. Unfortunately this has some major problems:pane:get_cursor_position
and disregard everything after the cursor. Which has the side effect that the cursor being anywhere but at the end of the typed text would be problematic. It's very fair to say this is not wezterm's concern 😅pane:get_lines_as_text
supposedly takes a param for number of lines, but passing any integer there made it return nothing in my experience. This may just be a bug.Beta Was this translation helpful? Give feedback.
All reactions