How do I find the length of readline's mode string (eg @
or (cmd)
or (ins)
) which is printed in front of the bash prompt? This mode string is activated by set show-mode-in-prompt on
in .inputrc
.
I want to determine the length of this string from within $PROMPT_COMMAND
.
I'm trying to do some cursor movement with tput
inside the prompt to print some info on the terminal's right hand side (so that it can be overwritten if need be), then resume printing the prompt on the left, but I need to take into account the length of the mode string.
Is $PROMPT_COMMAND
called again and the prompt reprinted if changing mode (e.g) emacs-mode-string
to vi-ins-mode-string
as the prefix?
tput
for this, though. – tripleee Apr 25 '17 at 13:24tput sc
to capture the current cursor position andètput rc` to return back there. – tripleee May 01 '17 at 14:48\e[s
and\e[u
. – Tom Hale May 02 '17 at 04:51