Skip to content
Browse files

shell: add Ctrl+N and Ctrl+P meta-keys

Ctrl+N - moves in history to next entry
Ctrl+P - moves in history to previous entry

Behavior of those meta-keys is the same as in bash and emacs, which
makes Zephyr shell even more familiar to play with.

Signed-off-by: Marcin Niestroj <>
  • Loading branch information...
mniestroj authored and nashif committed Jun 22, 2019
1 parent 74818bc commit 0d6fabe6c350376168d90762c0e0a7a931c15be3
Showing with 12 additions and 2 deletions.
  1. +8 −0 subsys/shell/shell.c
  2. +2 −2 subsys/shell/shell_cmds.c
  3. +2 −0 subsys/shell/shell_vt100.h
@@ -801,6 +801,14 @@ static void ctrl_metakeys_handle(const struct shell *shell, char data)

case SHELL_VT100_ASCII_CTRL_N: /* CTRL + N */
history_handle(shell, false);

case SHELL_VT100_ASCII_CTRL_P: /* CTRL + P */
history_handle(shell, true);

case SHELL_VT100_ASCII_CTRL_U: /* CTRL + U */
@@ -288,8 +288,8 @@ static int cmd_help(const struct shell *shell, size_t argc, char **argv)
"Shell supports following meta-keys:\n"
"Ctrl+a, Ctrl+b, Ctrl+c, Ctrl+d, Ctrl+e, Ctrl+f, Ctrl+k,"
" Ctrl+l, Ctrl+u, Ctrl+w\nAlt+b, Alt+f.\nPlease refer to"
" shell documentation for more details.");
" Ctrl+l, Ctrl+n, Ctrl+p, Ctrl+u, Ctrl+w\nAlt+b, Alt+f.\n"
"Please refer to shell documentation for more details.");

return 0;
@@ -18,6 +18,8 @@
#define SHELL_VT100_ASCII_CTRL_F (0x06)
#define SHELL_VT100_ASCII_CTRL_K (0x0B)
#define SHELL_VT100_ASCII_CTRL_L (0x0C)
#define SHELL_VT100_ASCII_CTRL_N (0x0E)
#define SHELL_VT100_ASCII_CTRL_P (0x10)
#define SHELL_VT100_ASCII_CTRL_U (0x15)
#define SHELL_VT100_ASCII_CTRL_W (0x17)
#define SHELL_VT100_ASCII_ALT_B (0x62)

0 comments on commit 0d6fabe

Please sign in to comment.
You can’t perform that action at this time.