Open user18130814200115-2 opened 2 months ago
Thanks for the suggestion.
Currently the prompt is only evaluated when starting a new line, so something like YASH_PS1='$LE_CURRENT_MODE \$ '
would not work even if the variable was exposed.
Possible solutions and alternatives:
I see the problem more clearly now, and I agree with you that re-drawing the prompt on every keypress is not a great way of handling this.
If it were possible to re-draw the prompt on mode change, set a prompt per mode, or have a redraw-prompt action which we might map alongside the mode switch. That would be great from a user's point of view (in my option), though it seems like a rather big change from the developer's point of view.
However, the cursor shape is also a great option, and perhaps more directly actionable.
One way to check if a given terminal supports cursor shape modification is DECRQSS. If the terminal in question supports DECRQSS, then \033P$q q\033\\
would return ^[P1$r
followed by the escape sequence to do so.
There may however be terminals which do implement cursor changing through CSIs, while not supporting DECRQSS. In this case we might be able to query terminfo, csr
, cnorm
, and cinvis
instead. That being said, Xterm has supported DECRQSS since 1996, and DECRQSS cursor change since 2012, so I think we should be fine.
When using yash, I am sometimes confused as to which mode I am in, specifailly vi-command or vi-insert. I would like to put this info in my prompt, though there seems to be no way to expose this to the end user.
I have done some digging through the code, and the LE_CURRENT_MODE variable seems to keep track of this, though it is not exported to the shell.
Would it be possible to export this variable for use in prompts and such?
Thanks, and keep up the great work