summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-choose-tree.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2013-03-21 16:10:00 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2013-03-21 16:10:00 +0000
commitc453333608305c138898896122c071c4a097b7c4 (patch)
tree01da80a10a789cca0f5cf1d6df418af14131e345 /usr.bin/tmux/cmd-choose-tree.c
parentbb2f551d2454279521f9535fe6fc2751e1bf5819 (diff)
Allow choose commands to be used outside tmux, so long as at least one
client is attached.
Diffstat (limited to 'usr.bin/tmux/cmd-choose-tree.c')
-rw-r--r--usr.bin/tmux/cmd-choose-tree.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.bin/tmux/cmd-choose-tree.c b/usr.bin/tmux/cmd-choose-tree.c
index 8c3210b8304..b23d05c7239 100644
--- a/usr.bin/tmux/cmd-choose-tree.c
+++ b/usr.bin/tmux/cmd-choose-tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-choose-tree.c,v 1.15 2013/03/21 16:09:17 nicm Exp $ */
+/* $OpenBSD: cmd-choose-tree.c,v 1.16 2013/03/21 16:09:59 nicm Exp $ */
/*
* Copyright (c) 2012 Thomas Adam <thomas@xteddy.org>
@@ -71,6 +71,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
struct args *args = self->args;
struct winlink *wl, *wm;
struct session *s, *s2;
+ struct client *c;
struct window_choose_data *wcd = NULL;
const char *ses_template, *win_template;
char *final_win_action, *cur_win_template;
@@ -83,12 +84,13 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
ses_template = win_template = NULL;
ses_action = win_action = NULL;
- if (ctx->curclient == NULL) {
- ctx->error(ctx, "must be run interactively");
+ if ((c = cmd_current_client(ctx)) == NULL) {
+ ctx->error(ctx, "no client available");
return (CMD_RETURN_ERROR);
}
- s = ctx->curclient->session;
+ if ((s = c->session) == NULL)
+ return (CMD_RETURN_ERROR);
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
return (CMD_RETURN_ERROR);
@@ -172,7 +174,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
}
wcd = window_choose_add_session(wl->window->active,
- ctx, s2, ses_template, (char *)ses_action, idx_ses);
+ c, s2, ses_template, (char *)ses_action, idx_ses);
/* If we're just choosing sessions, skip choosing windows. */
if (sflag && !wflag) {
@@ -210,7 +212,7 @@ windows_only:
cur_win_template = final_win_template_last;
window_choose_add_window(wl->window->active,
- ctx, s2, wm, cur_win_template,
+ c, s2, wm, cur_win_template,
final_win_action,
(wflag && !sflag) ? win_ses : idx_ses);