Add an additional {} syntax for defining strings in the configuration

file, making it much tidier to define commands that contain other tmux
or shell commands (like if-shell). Also tweak bind-key to expect a
string if it is only given one argument, so {} can be used with it as
well. From Avi Halachmi.
This commit is contained in:
nicm
2019-05-27 12:16:27 +00:00
parent 65e5e14561
commit 6b332127ca
5 changed files with 157 additions and 21 deletions

View File

@ -44,14 +44,16 @@ const struct cmd_entry cmd_bind_key_entry = {
static enum cmd_retval
cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = self->args;
key_code key;
const char *tablename;
struct cmd_parse_result *pr;
struct args *args = self->args;
key_code key;
const char *tablename;
struct cmd_parse_result *pr;
char **argv = args->argv;
int argc = args->argc;
key = key_string_lookup_string(args->argv[0]);
key = key_string_lookup_string(argv[0]);
if (key == KEYC_NONE || key == KEYC_UNKNOWN) {
cmdq_error(item, "unknown key: %s", args->argv[0]);
cmdq_error(item, "unknown key: %s", argv[0]);
return (CMD_RETURN_ERROR);
}
@ -62,7 +64,10 @@ cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
else
tablename = "prefix";
pr = cmd_parse_from_arguments(args->argc - 1, args->argv + 1, NULL);
if (argc == 2)
pr = cmd_parse_from_string(argv[1], NULL);
else
pr = cmd_parse_from_arguments(argc - 1, argv + 1, NULL);
switch (pr->status) {
case CMD_PARSE_EMPTY:
cmdq_error(item, "empty command");