=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-list-keys.c,v retrieving revision 1.51 retrieving revision 1.52 diff -u -r1.51 -r1.52 --- src/usr.bin/tmux/cmd-list-keys.c 2020/02/15 15:08:08 1.51 +++ src/usr.bin/tmux/cmd-list-keys.c 2020/04/05 08:40:31 1.52 @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list-keys.c,v 1.51 2020/02/15 15:08:08 nicm Exp $ */ +/* $OpenBSD: cmd-list-keys.c,v 1.52 2020/04/05 08:40:31 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -47,8 +47,8 @@ .name = "list-commands", .alias = "lscm", - .args = { "F:", 0, 0 }, - .usage = "[-F format]", + .args = { "F:", 0, 1 }, + .usage = "[-F format] [command]", .flags = CMD_STARTSERVER|CMD_AFTERHOOK, .exec = cmd_list_keys_exec @@ -317,9 +317,12 @@ const struct cmd_entry **entryp; const struct cmd_entry *entry; struct format_tree *ft; - const char *template, *s; + const char *template, *s, *command = NULL; char *line; + if (args->argc != 0) + command = args->argv[0]; + if ((template = args_get(args, 'F')) == NULL) { template = "#{command_list_name}" "#{?command_list_alias, (#{command_list_alias}),} " @@ -331,6 +334,11 @@ for (entryp = cmd_table; *entryp != NULL; entryp++) { entry = *entryp; + if (command != NULL && + (strcmp(entry->name, command) != 0 && + (entry->alias == NULL || + strcmp(entry->alias, command) != 0))) + continue; format_add(ft, "command_list_name", "%s", entry->name); if (entry->alias != NULL)