Skip to content

Commit cf03713

Browse files
committed
[gdb/cli] Document \001 and \002 usage for set prompt
PR cli/28887 reports the following problem when using a custom prompt. First, we set up the custom prompt (with ^ marking the position of the blinking cursor on the line above): ... $ gdb -q -ex "set prompt \033[31mgdb$ \033[0m" gdb$ ^ ... Then we type some string, and enter it into the command history: ... gdb$ some long command ❌️ Undefined command: "some". Try "help". gdb$ ^ ... We use C-p to fetch the previous command: ... gdb$ some long command ^ ... Sofar, so good. Finally, we use C-a which should move the cursor to just after the prompt, but instead we get: ... gdb$ some long command ^ ... This is fixed by using \001 and \002: ... (gdb) set prompt \001\033[31m\002gdb$ \001\033[0m\002 ... aka as RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE [1]. Add an example to the documentation showing the use of these markers. The added example is the equivalent of the "\[\e[0;34m\](gdb)\[\e[0m\]" example documented at gdb.prompt.substitute_string that can be used with "set extended-prompt". While working on this, I noticed that "show prompt" doesn't show back the original string, using '\e' instead of '\033': ... gdb$ show prompt Gdb's prompt is "\001\e[31m\002gdb$ \001\e[0m\002". ... and that the shown string can't be used as an argument to "set prompt": ... gdb$ set prompt \001\e[31m\002gdb$ \001\e[0m\002 e[31mgdb$ e[0m ... I've filed this as PR cli/33184. Approved-By: Eli Zaretskii <[email protected]> [1] https://tiswww.case.edu/php/chet/readline/readline.html
1 parent 2f108d5 commit cf03713

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

gdb/doc/gdb.texinfo

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27659,6 +27659,16 @@ or a prompt that does not.
2765927659
@item set prompt @var{newprompt}
2766027660
Directs @value{GDBN} to use @var{newprompt} as its prompt string henceforth.
2766127661

27662+
For example, this will set a blue-colored ``(gdb)'' prompt:
27663+
27664+
@smallexample
27665+
set prompt \001\033[0;34m\002(gdb)\001\033[0m\002
27666+
@end smallexample
27667+
27668+
It uses @samp{\001} and @samp{\002} to begin and end a sequence of
27669+
non-printing characters, to make sure they're not counted in the string
27670+
length.
27671+
2766227672
@kindex show prompt
2766327673
@item show prompt
2766427674
Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}}

0 commit comments

Comments
 (0)