term.cursor_position

term

cursor_position() -> line, col

Query the terminal for the current cursor position

Sends a CPR request (ESC [ 6 n) and reads the response (ESC [ row ; col R). Requires a TTY; typically called while the terminal is in raw mode. Returns nil on parse failure or if the terminal does not respond with the expected sequence.