aboutsummaryrefslogtreecommitdiff
path: root/cmd.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2013-03-11 21:31:46 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2013-03-11 21:31:46 +0000
commit543420ccd2c3c23437405b391e3f9fe1d05223f7 (patch)
tree7581f8eb90cd26fd51c5e406f31f561e0e4eb603 /cmd.c
parent064022548bcbf4d45705fdbff8441f2b5da5f682 (diff)
parent7c009509676b4580065fdc6f0084a93b9758fac0 (diff)
downloadrtmux-543420ccd2c3c23437405b391e3f9fe1d05223f7.tar.gz
rtmux-543420ccd2c3c23437405b391e3f9fe1d05223f7.tar.bz2
rtmux-543420ccd2c3c23437405b391e3f9fe1d05223f7.zip
Merge branch 'master' of ssh://git.code.sf.net/p/tmux/tmux-code
Diffstat (limited to 'cmd.c')
-rw-r--r--cmd.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/cmd.c b/cmd.c
index 0d6a85ff..c8e9702d 100644
--- a/cmd.c
+++ b/cmd.c
@@ -112,6 +112,7 @@ const struct cmd_entry *cmd_table[] = {
&cmd_switch_client_entry,
&cmd_unbind_key_entry,
&cmd_unlink_window_entry,
+ &cmd_wait_for_entry,
NULL
};
@@ -121,6 +122,7 @@ struct session *cmd_choose_session(int);
struct client *cmd_choose_client(struct clients *);
struct client *cmd_lookup_client(const char *);
struct session *cmd_lookup_session(const char *, int *);
+struct session *cmd_lookup_session_id(const char *);
struct winlink *cmd_lookup_window(struct session *, const char *, int *);
int cmd_lookup_index(struct session *, const char *, int *);
struct window_pane *cmd_lookup_paneid(const char *);
@@ -356,8 +358,8 @@ cmd_current_session(struct cmd_q *cmdq, int prefer_unattached)
}
/* Use the session from the TMUX environment variable. */
- if (data != NULL && data->pid == getpid() && data->idx != -1) {
- s = session_find_by_index(data->idx);
+ if (data != NULL && data->pid == getpid() && data->session_id != -1) {
+ s = session_find_by_id(data->session_id);
if (s != NULL)
return (s);
}
@@ -549,6 +551,21 @@ cmd_lookup_client(const char *name)
return (NULL);
}
+/* Find the target session or report an error and return NULL. */
+struct session *
+cmd_lookup_session_id(const char *arg)
+{
+ char *endptr;
+ long id;
+
+ if (arg[0] != '$')
+ return (NULL);
+ id = strtol(arg + 1, &endptr, 10);
+ if (arg[1] != '\0' && *endptr == '\0')
+ return (session_find_by_id(id));
+ return (NULL);
+}
+
/* Lookup a session by name. If no session is found, NULL is returned. */
struct session *
cmd_lookup_session(const char *name, int *ambiguous)
@@ -557,6 +574,10 @@ cmd_lookup_session(const char *name, int *ambiguous)
*ambiguous = 0;
+ /* Look for $id first. */
+ if ((s = cmd_lookup_session_id(name)) != NULL)
+ return (s);
+
/*
* Look for matches. First look for exact matches - session names must
* be unique so an exact match can't be ambigious and can just be