cmdtree

A trie command launcher for X11
git clone git://jb55.com/cmdtree
Log | Files | Refs | README | LICENSE

commit 8a60b03a0119c5ae071952dd5915f2741b3fe4f2
parent e15c139924df0b56f376ebdeb01c56852de50984
Author: William Casarin <jb55@jb55.com>
Date:   Mon,  9 Jul 2018 20:05:58 -0700

allow name to be different from command

Diffstat:
Mcfg.def.h | 7++++---
Mcmdtree.c | 1-
Mcommand.c | 3++-
Mcommand.h | 1+
4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/cfg.def.h b/cfg.def.h @@ -45,7 +45,7 @@ static struct command browser_commands[] = { { .bind = "f", .name = "firefox", .nchildren = 0, .children = NULL }, }; -static const struct command commands[] = { +static struct command commands[] = { { .bind = "b", .name = "browsers", .nchildren = LENGTH(browser_commands), @@ -53,8 +53,9 @@ static const struct command commands[] = { }, { .bind = "e", - .name = "emacs-dev", - .children = NULL, + .name = "emacs", + .command = "emacs-dev", + .children = 0, .nchildren = 0 }, }; diff --git a/cmdtree.c b/cmdtree.c @@ -41,7 +41,6 @@ static XIC xic; #include "cfg.h" - static int cmdstack_push_(struct command *children, int nchildren) { if (cmdstack_ptr + 1 >= CMDSTACK_SIZE) diff --git a/command.c b/command.c @@ -17,7 +17,8 @@ command_is_prefix(struct command *cmd) { void command_exec(struct command *cmd) { - execlp("/bin/sh", "sh", "-c", cmd->name, (char *) 0); + const char *cmdname = cmd->command == NULL ? cmd->name : cmd->command; + execlp("/bin/sh", "sh", "-c", cmdname, (char *) 0); err(1, "executing command %s", cmd->name); } diff --git a/command.h b/command.h @@ -6,6 +6,7 @@ struct command { char *name; + char *command; char *bind; struct command *children; int nchildren;