diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 6d5fcb9..15152b1 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
#define PROMPT_ON COLOR_BLUE "[mgmt]" COLOR_OFF "# "
+static void update_prompt(uint16_t index)
+{
+ char str[32];
+
+ if (index == MGMT_INDEX_NONE)
+ snprintf(str, sizeof(str), "%s# ",
+ COLOR_BLUE "[mgmt]" COLOR_OFF);
+ else
+ snprintf(str, sizeof(str),
+ COLOR_BLUE "[hci%u]" COLOR_OFF "# ", index);
+
+ if (saved_prompt) {
+ free(saved_prompt);
+ saved_prompt = strdup(str);
+ return;
+ }
+
+ rl_set_prompt(str);
+}
+
static void noninteractive_quit(int status)
{
if (interactive)
register_mgmt_callbacks(mgmt, mgmt_index);
print("Selected index %u", mgmt_index);
+
+ update_prompt(mgmt_index);
}
static struct cmd_info interactive_cmd[] = {
rl_erase_empty_line = 1;
rl_callback_handler_install(NULL, rl_handler);
- rl_set_prompt(PROMPT_ON);
+ update_prompt(index);
rl_redisplay();
}