diff --git a/options-table.c b/options-table.c index a461b3ea..3d1b4f85 100644 --- a/options-table.c +++ b/options-table.c @@ -285,6 +285,13 @@ const struct options_table_entry options_table[] = { .text = "Style of the cursor." }, + { .name = "default-client-command", + .type = OPTIONS_TABLE_COMMAND, + .scope = OPTIONS_TABLE_SERVER, + .default_str = "new-session", + .text = "Default command to run when tmux is run without a command." + }, + { .name = "default-terminal", .type = OPTIONS_TABLE_STRING, .scope = OPTIONS_TABLE_SERVER, diff --git a/server-client.c b/server-client.c index 30cf5280..ae2e54f9 100644 --- a/server-client.c +++ b/server-client.c @@ -3448,6 +3448,7 @@ server_client_dispatch_command(struct client *c, struct imsg *imsg) struct cmd_parse_result *pr; struct args_value *values; struct cmdq_item *new_item; + struct cmd_list *cmdlist; if (c->flags & CLIENT_EXIT) return; @@ -3468,33 +3469,33 @@ server_client_dispatch_command(struct client *c, struct imsg *imsg) } if (argc == 0) { - argc = 1; - argv = xcalloc(1, sizeof *argv); - *argv = xstrdup("new-session"); + cmdlist = cmd_list_copy(options_get_command(global_options, + "default-client-command"), 0, NULL); + } else { + values = args_from_vector(argc, argv); + pr = cmd_parse_from_arguments(values, argc, NULL); + switch (pr->status) { + case CMD_PARSE_ERROR: + cause = pr->error; + goto error; + case CMD_PARSE_SUCCESS: + break; + } + args_free_values(values, argc); + free(values); + cmd_free_argv(argc, argv); + cmdlist = pr->cmdlist; } - values = args_from_vector(argc, argv); - pr = cmd_parse_from_arguments(values, argc, NULL); - switch (pr->status) { - case CMD_PARSE_ERROR: - cause = pr->error; - goto error; - case CMD_PARSE_SUCCESS: - break; - } - args_free_values(values, argc); - free(values); - cmd_free_argv(argc, argv); - if ((c->flags & CLIENT_READONLY) && - !cmd_list_all_have(pr->cmdlist, CMD_READONLY)) + !cmd_list_all_have(cmdlist, CMD_READONLY)) new_item = cmdq_get_callback(server_client_read_only, NULL); else - new_item = cmdq_get_command(pr->cmdlist, NULL); + new_item = cmdq_get_command(cmdlist, NULL); cmdq_append(c, new_item); cmdq_append(c, cmdq_get_callback(server_client_command_done, NULL)); - cmd_list_free(pr->cmdlist); + cmd_list_free(cmdlist); return; error: diff --git a/tmux.1 b/tmux.1 index 7a2aad7a..ac9797b5 100644 --- a/tmux.1 +++ b/tmux.1 @@ -254,9 +254,10 @@ was given) and off. This specifies one of a set of commands used to control .Nm , as described in the following sections. -If no commands are specified, the -.Ic new-session -command is assumed. +If no commands are specified, the command in +.Ic default-client-command +is assumed, which defaults to +.Ic new-session . .El .Sh DEFAULT KEY BINDINGS .Nm @@ -4085,6 +4086,10 @@ where the number is a hexadecimal number. Give the command to pipe to if the .Ic copy-pipe copy mode command is used without arguments. +.It Ic default-client-command Ar command +Set the default command to run when tmux is called without a command. +The default is +.Ic new-session . .It Ic default-terminal Ar terminal Set the default terminal for new windows created in this session - the default value of the