Hi Looks good, but I think we should take PATH from the session or global environment if a suitable client is not around. Modified diff below.
Not certain about using the cmdq client PATH rather than always session... although it feels better so I guess go with it. Problem is no clear rules for where everything comes from. Ages ago the idea was that "tmux neww" and "C-b : neww" should get the same thing but that generally was a little surprising. So now some stuff comes from the cmd client (cwd), some from the session (termios, rest of the environ) and some from config (shell). And respawn and jobs have another mixture... needs rethought I think, and seems like spawning something could be common code. Index: cmd-new-session.c =================================================================== RCS file: /cvs/src/usr.bin/tmux/cmd-new-session.c,v retrieving revision 1.57 diff -u -p -r1.57 cmd-new-session.c --- cmd-new-session.c 23 Feb 2014 00:53:06 -0000 1.57 +++ cmd-new-session.c 14 Apr 2014 22:47:41 -0000 @@ -55,10 +55,11 @@ cmd_new_session_exec(struct cmd *self, s struct environ env; struct termios tio, *tiop; const char *newname, *target, *update, *errstr, *template; - char *cmd, *cause, *cp; + char *path, *cmd, *cause, *cp; int detached, already_attached, idx, cwd, fd = -1; u_int sx, sy; struct format_tree *ft; + struct environ_entry *envent; if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n'))) { cmdq_error(cmdq, "command or window name given with target"); @@ -189,6 +190,14 @@ cmd_new_session_exec(struct cmd *self, s else cmd = options_get_string(&global_s_options, "default-command"); + path = NULL; + if (c != NULL && c->session == NULL) + envent = environ_find(&c->environ, "PATH"); + else + envent = environ_find(&global_environ, "PATH"); + if (envent != NULL) + path = envent->value; + /* Construct the environment. */ environ_init(&env); update = options_get_string(&global_s_options, "update-environment"); @@ -197,7 +206,8 @@ cmd_new_session_exec(struct cmd *self, s /* Create the new session. */ idx = -1 - options_get_number(&global_s_options, "base-index"); - s = session_create(newname, cmd, cwd, &env, tiop, idx, sx, sy, &cause); + s = session_create(newname, cmd, path, cwd, &env, tiop, idx, sx, sy, + &cause); if (s == NULL) { cmdq_error(cmdq, "create session failed: %s", cause); free(cause); Index: cmd-new-window.c =================================================================== RCS file: /cvs/src/usr.bin/tmux/cmd-new-window.c,v retrieving revision 1.38 diff -u -p -r1.38 cmd-new-window.c --- cmd-new-window.c 23 Nov 2013 09:18:29 -0000 1.38 +++ cmd-new-window.c 14 Apr 2014 22:47:41 -0000 @@ -49,10 +49,11 @@ cmd_new_window_exec(struct cmd *self, st struct session *s; struct winlink *wl; struct client *c; - const char *cmd, *template; + const char *cmd, *path, *template; char *cause, *cp; int idx, last, detached, cwd, fd = -1; struct format_tree *ft; + struct environ_entry *envent; if (args_has(args, 'a')) { wl = cmd_find_window(cmdq, args_get(args, 't'), &s); @@ -77,7 +78,8 @@ cmd_new_window_exec(struct cmd *self, st server_unlink_window(s, wl); } } else { - if ((idx = cmd_find_index(cmdq, args_get(args, 't'), &s)) == -2) + idx = cmd_find_index(cmdq, args_get(args, 't'), &s); + if (idx == -2) return (CMD_RETURN_ERROR); } detached = args_has(args, 'd'); @@ -87,6 +89,14 @@ cmd_new_window_exec(struct cmd *self, st else cmd = args->argv[0]; + path = NULL; + if (cmdq->client != NULL && cmdq->client->session == NULL) + envent = environ_find(&cmdq->client->environ, "PATH"); + else + envent = environ_find(&s->environ, "PATH"); + if (envent != NULL) + path = envent->value; + if (args_has(args, 'c')) { ft = format_create(); if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL) @@ -135,7 +145,7 @@ cmd_new_window_exec(struct cmd *self, st if (idx == -1) idx = -1 - options_get_number(&s->options, "base-index"); - wl = session_new(s, args_get(args, 'n'), cmd, cwd, idx, &cause); + wl = session_new(s, args_get(args, 'n'), cmd, path, cwd, idx, &cause); if (wl == NULL) { cmdq_error(cmdq, "create window failed: %s", cause); free(cause); Index: cmd-respawn-pane.c =================================================================== RCS file: /cvs/src/usr.bin/tmux/cmd-respawn-pane.c,v retrieving revision 1.10 diff -u -p -r1.10 cmd-respawn-pane.c --- cmd-respawn-pane.c 10 Oct 2013 12:29:53 -0000 1.10 +++ cmd-respawn-pane.c 14 Apr 2014 22:47:41 -0000 @@ -48,9 +48,10 @@ cmd_respawn_pane_exec(struct cmd *self, struct window_pane *wp; struct session *s; struct environ env; - const char *cmd; + const char *cmd, *path; char *cause; u_int idx; + struct environ_entry *envent; if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL) return (CMD_RETURN_ERROR); @@ -77,7 +78,17 @@ cmd_respawn_pane_exec(struct cmd *self, cmd = args->argv[0]; else cmd = NULL; - if (window_pane_spawn(wp, cmd, NULL, -1, &env, s->tio, &cause) != 0) { + + path = NULL; + if (cmdq->client != NULL && cmdq->client->session == NULL) + envent = environ_find(&cmdq->client->environ, "PATH"); + else + envent = environ_find(&s->environ, "PATH"); + if (envent != NULL) + path = envent->value; + + if (window_pane_spawn(wp, cmd, path, NULL, -1, &env, s->tio, + &cause) != 0) { cmdq_error(cmdq, "respawn pane failed: %s", cause); free(cause); environ_free(&env); Index: cmd-respawn-window.c =================================================================== RCS file: /cvs/src/usr.bin/tmux/cmd-respawn-window.c,v retrieving revision 1.20 diff -u -p -r1.20 cmd-respawn-window.c --- cmd-respawn-window.c 10 Oct 2013 12:29:53 -0000 1.20 +++ cmd-respawn-window.c 14 Apr 2014 22:47:41 -0000 @@ -47,8 +47,9 @@ cmd_respawn_window_exec(struct cmd *self struct window_pane *wp; struct session *s; struct environ env; - const char *cmd; + const char *cmd, *path; char *cause; + struct environ_entry *envent; if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL) return (CMD_RETURN_ERROR); @@ -79,7 +80,17 @@ cmd_respawn_window_exec(struct cmd *self cmd = args->argv[0]; else cmd = NULL; - if (window_pane_spawn(wp, cmd, NULL, -1, &env, s->tio, &cause) != 0) { + + path = NULL; + if (cmdq->client != NULL && cmdq->client->session == NULL) + envent = environ_find(&cmdq->client->environ, "PATH"); + else + envent = environ_find(&s->environ, "PATH"); + if (envent != NULL) + path = envent->value; + + if (window_pane_spawn(wp, cmd, path, NULL, -1, &env, s->tio, + &cause) != 0) { cmdq_error(cmdq, "respawn window failed: %s", cause); free(cause); environ_free(&env); Index: cmd-split-window.c =================================================================== RCS file: /cvs/src/usr.bin/tmux/cmd-split-window.c,v retrieving revision 1.48 diff -u -p -r1.48 cmd-split-window.c --- cmd-split-window.c 22 Nov 2013 20:58:36 -0000 1.48 +++ cmd-split-window.c 14 Apr 2014 22:47:41 -0000 @@ -61,7 +61,7 @@ cmd_split_window_exec(struct cmd *self, struct window *w; struct window_pane *wp, *new_wp = NULL; struct environ env; - const char *cmd, *shell, *template; + const char *cmd, *path, *shell, *template; char *cause, *new_cause, *cp; u_int hlimit; int size, percentage, cwd, fd = -1; @@ -69,6 +69,7 @@ cmd_split_window_exec(struct cmd *self, struct layout_cell *lc; struct client *c; struct format_tree *ft; + struct environ_entry *envent; if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL) return (CMD_RETURN_ERROR); @@ -148,8 +149,17 @@ cmd_split_window_exec(struct cmd *self, goto error; } new_wp = window_add_pane(w, hlimit); + + path = NULL; + if (cmdq->client != NULL && cmdq->client->session == NULL) + envent = environ_find(&cmdq->client->environ, "PATH"); + else + envent = environ_find(&s->environ, "PATH"); + if (envent != NULL) + path = envent->value; + if (window_pane_spawn( - new_wp, cmd, shell, cwd, &env, s->tio, &cause) != 0) + new_wp, cmd, path, shell, cwd, &env, s->tio, &cause) != 0) goto error; layout_assign_pane(lc, new_wp); Index: session.c =================================================================== RCS file: /cvs/src/usr.bin/tmux/session.c,v retrieving revision 1.42 diff -u -p -r1.42 session.c --- session.c 22 Jan 2014 14:00:08 -0000 1.42 +++ session.c 14 Apr 2014 22:47:41 -0000 @@ -85,8 +85,9 @@ session_find_by_id(u_int id) /* Create a new session. */ struct session * -session_create(const char *name, const char *cmd, int cwd, struct environ *env, - struct termios *tio, int idx, u_int sx, u_int sy, char **cause) +session_create(const char *name, const char *cmd, const char *path, int cwd, + struct environ *env, struct termios *tio, int idx, u_int sx, u_int sy, + char **cause) { struct session *s; @@ -132,7 +133,7 @@ session_create(const char *name, const c RB_INSERT(sessions, &sessions, s); if (cmd != NULL) { - if (session_new(s, NULL, cmd, cwd, idx, cause) == NULL) { + if (session_new(s, NULL, cmd, path, cwd, idx, cause) == NULL) { session_destroy(s); return (NULL); } @@ -226,8 +227,8 @@ session_previous_session(struct session /* Create a new window on a session. */ struct winlink * -session_new(struct session *s, const char *name, const char *cmd, int cwd, - int idx, char **cause) +session_new(struct session *s, const char *name, const char *cmd, + const char *path, int cwd, int idx, char **cause) { struct window *w; struct winlink *wl; @@ -250,8 +251,8 @@ session_new(struct session *s, const cha shell = _PATH_BSHELL; hlimit = options_get_number(&s->options, "history-limit"); - w = window_create(name, cmd, shell, cwd, &env, s->tio, s->sx, s->sy, - hlimit, cause); + w = window_create(name, cmd, path, shell, cwd, &env, s->tio, s->sx, + s->sy, hlimit, cause); if (w == NULL) { winlink_remove(&s->windows, wl); environ_free(&env); Index: tmux.h =================================================================== RCS file: /cvs/src/usr.bin/tmux/tmux.h,v retrieving revision 1.448 diff -u -p -r1.448 tmux.h --- tmux.h 3 Apr 2014 08:20:29 -0000 1.448 +++ tmux.h 14 Apr 2014 22:47:41 -0000 @@ -2130,9 +2130,9 @@ void winlink_stack_remove(struct winli int window_index(struct window *, u_int *); struct window *window_find_by_id(u_int); struct window *window_create1(u_int, u_int); -struct window *window_create(const char *, const char *, const char *, int, - struct environ *, struct termios *, u_int, u_int, u_int, - char **); +struct window *window_create(const char *, const char *, const char *, + const char *, int, struct environ *, struct termios *, + u_int, u_int, u_int, char **); void window_destroy(struct window *); struct window_pane *window_get_active_at(struct window *, u_int, u_int); void window_set_active_at(struct window *, u_int, u_int); @@ -2156,8 +2156,8 @@ struct window_pane *window_pane_create(s void window_pane_destroy(struct window_pane *); void window_pane_timer_start(struct window_pane *); int window_pane_spawn(struct window_pane *, const char *, - const char *, int, struct environ *, struct termios *, - char **); + const char *, const char *, int, struct environ *, + struct termios *, char **); void window_pane_resize(struct window_pane *, u_int, u_int); void window_pane_alternate_on(struct window_pane *, struct grid_cell *, int); @@ -2293,7 +2293,7 @@ RB_PROTOTYPE(sessions, session, entry, s int session_alive(struct session *); struct session *session_find(const char *); struct session *session_find_by_id(u_int); -struct session *session_create(const char *, const char *, int, +struct session *session_create(const char *, const char *, const char *, int, struct environ *, struct termios *, int, u_int, u_int, char **); void session_destroy(struct session *); @@ -2301,8 +2301,8 @@ int session_check_name(const char *); void session_update_activity(struct session *); struct session *session_next_session(struct session *); struct session *session_previous_session(struct session *); -struct winlink *session_new(struct session *, const char *, const char *, int, - int, char **); +struct winlink *session_new(struct session *, const char *, const char *, + const char *, int, int, char **); struct winlink *session_attach( struct session *, struct window *, int, char **); int session_detach(struct session *, struct winlink *); Index: window.c =================================================================== RCS file: /cvs/src/usr.bin/tmux/window.c,v retrieving revision 1.103 diff -u -p -r1.103 window.c --- window.c 31 Mar 2014 21:41:07 -0000 1.103 +++ window.c 14 Apr 2014 22:47:41 -0000 @@ -312,8 +312,8 @@ window_create1(u_int sx, u_int sy) } struct window * -window_create(const char *name, const char *cmd, const char *shell, - int cwd, struct environ *env, struct termios *tio, +window_create(const char *name, const char *cmd, const char *path, + const char *shell, int cwd, struct environ *env, struct termios *tio, u_int sx, u_int sy, u_int hlimit, char **cause) { struct window *w; @@ -323,7 +323,8 @@ window_create(const char *name, const ch wp = window_add_pane(w, hlimit); layout_init(w, wp); - if (window_pane_spawn(wp, cmd, shell, cwd, env, tio, cause) != 0) { + if (window_pane_spawn(wp, cmd, path, shell, cwd, env, tio, + cause) != 0) { window_destroy(w); return (NULL); } @@ -810,8 +811,9 @@ window_pane_destroy(struct window_pane * } int -window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell, - int cwd, struct environ *env, struct termios *tio, char **cause) +window_pane_spawn(struct window_pane *wp, const char *cmd, const char *path, + const char *shell, int cwd, struct environ *env, struct termios *tio, + char **cause) { struct winsize ws; char *argv0, paneid[16]; @@ -860,6 +862,8 @@ window_pane_spawn(struct window_pane *wp closefrom(STDERR_FILENO + 1); + if (path != NULL) + environ_set(env, "PATH", path); xsnprintf(paneid, sizeof paneid, "%%%u", wp->id); environ_set(env, "TMUX_PANE", paneid); environ_push(env); On Tue, Mar 11, 2014 at 07:05:02PM -0500, J Raynor wrote: > I've attached a patch that just does the PATH bits. > diff --git a/cmd-new-session.c b/cmd-new-session.c > index 15e411d..8953820 100644 > --- a/cmd-new-session.c > +++ b/cmd-new-session.c > @@ -54,11 +54,12 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) > struct window *w; > struct environ env; > struct termios tio, *tiop; > - const char *newname, *target, *update, *errstr, *template; > + const char *newname, *target, *update, *errstr, *template, > *path; > char *cmd, *cause, *cp; > int detached, already_attached, idx, cwd, fd = -1; > u_int sx, sy; > struct format_tree *ft; > + struct environ_entry *envent; > > if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n'))) { > cmdq_error(cmdq, "command or window name given with target"); > @@ -189,6 +190,13 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q > *cmdq) > else > cmd = options_get_string(&global_s_options, "default-command"); > > + path = NULL; > + if (c != NULL && c->session == NULL) { > + envent = environ_find(&c->environ, "PATH"); > + if (envent != NULL) > + path = envent->value; > + } > + > /* Construct the environment. */ > environ_init(&env); > update = options_get_string(&global_s_options, "update-environment"); > @@ -197,7 +205,8 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) > > /* Create the new session. */ > idx = -1 - options_get_number(&global_s_options, "base-index"); > - s = session_create(newname, cmd, cwd, &env, tiop, idx, sx, sy, &cause); > + s = session_create(newname, cmd, path, cwd, &env, tiop, idx, > + sx, sy, &cause); > if (s == NULL) { > cmdq_error(cmdq, "create session failed: %s", cause); > free(cause); > diff --git a/cmd-new-window.c b/cmd-new-window.c > index 58a5eb6..50b012a 100644 > --- a/cmd-new-window.c > +++ b/cmd-new-window.c > @@ -49,10 +49,11 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq) > struct session *s; > struct winlink *wl; > struct client *c; > - const char *cmd, *template; > + const char *cmd, *path, *template; > char *cause, *cp; > int idx, last, detached, cwd, fd = -1; > struct format_tree *ft; > + struct environ_entry *envent; > > if (args_has(args, 'a')) { > wl = cmd_find_window(cmdq, args_get(args, 't'), &s); > @@ -87,6 +88,13 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq) > else > cmd = args->argv[0]; > > + path = NULL; > + if (cmdq->client != NULL && cmdq->client->session == NULL) { > + envent = environ_find(&cmdq->client->environ, "PATH"); > + if (envent != NULL) > + path = envent->value; > + } > + > if (args_has(args, 'c')) { > ft = format_create(); > if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL) > @@ -135,7 +143,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq) > > if (idx == -1) > idx = -1 - options_get_number(&s->options, "base-index"); > - wl = session_new(s, args_get(args, 'n'), cmd, cwd, idx, &cause); > + wl = session_new(s, args_get(args, 'n'), cmd, path, cwd, idx, &cause); > if (wl == NULL) { > cmdq_error(cmdq, "create window failed: %s", cause); > free(cause); > diff --git a/cmd-respawn-pane.c b/cmd-respawn-pane.c > index bcde275..fbd8264 100644 > --- a/cmd-respawn-pane.c > +++ b/cmd-respawn-pane.c > @@ -48,9 +48,10 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmd_q *cmdq) > struct window_pane *wp; > struct session *s; > struct environ env; > - const char *cmd; > + const char *cmd, *path; > char *cause; > u_int idx; > + struct environ_entry *envent; > > if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL) > return (CMD_RETURN_ERROR); > @@ -77,7 +78,16 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmd_q *cmdq) > cmd = args->argv[0]; > else > cmd = NULL; > - if (window_pane_spawn(wp, cmd, NULL, -1, &env, s->tio, &cause) != 0) { > + > + path = NULL; > + if (cmdq->client != NULL && cmdq->client->session == NULL) { > + envent = environ_find(&cmdq->client->environ, "PATH"); > + if (envent != NULL) > + path = envent->value; > + } > + > + if (window_pane_spawn( > + wp, cmd, path, NULL, -1, &env, s->tio, &cause) != 0) { > cmdq_error(cmdq, "respawn pane failed: %s", cause); > free(cause); > environ_free(&env); > diff --git a/cmd-respawn-window.c b/cmd-respawn-window.c > index e6d913c..5d5f326 100644 > --- a/cmd-respawn-window.c > +++ b/cmd-respawn-window.c > @@ -47,8 +47,9 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_q > *cmdq) > struct window_pane *wp; > struct session *s; > struct environ env; > - const char *cmd; > + const char *cmd, *path; > char *cause; > + struct environ_entry *envent; > > if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL) > return (CMD_RETURN_ERROR); > @@ -79,7 +80,16 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_q > *cmdq) > cmd = args->argv[0]; > else > cmd = NULL; > - if (window_pane_spawn(wp, cmd, NULL, -1, &env, s->tio, &cause) != 0) { > + > + path = NULL; > + if (cmdq->client != NULL && cmdq->client->session == NULL) { > + envent = environ_find(&cmdq->client->environ, "PATH"); > + if (envent != NULL) > + path = envent->value; > + } > + > + if (window_pane_spawn( > + wp, cmd, path, NULL, -1, &env, s->tio, &cause) != 0) { > cmdq_error(cmdq, "respawn window failed: %s", cause); > free(cause); > environ_free(&env); > diff --git a/cmd-split-window.c b/cmd-split-window.c > index c43cb96..22a91c9 100644 > --- a/cmd-split-window.c > +++ b/cmd-split-window.c > @@ -60,7 +60,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq) > struct window *w; > struct window_pane *wp, *new_wp = NULL; > struct environ env; > - const char *cmd, *shell, *template; > + const char *cmd, *path, *shell, *template; > char *cause, *new_cause, *cp; > u_int hlimit; > int size, percentage, cwd, fd = -1; > @@ -68,6 +68,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq) > struct layout_cell *lc; > struct client *c; > struct format_tree *ft; > + struct environ_entry *envent; > > if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL) > return (CMD_RETURN_ERROR); > @@ -147,8 +148,16 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q > *cmdq) > goto error; > } > new_wp = window_add_pane(w, hlimit); > + > + path = NULL; > + if (cmdq->client != NULL && cmdq->client->session == NULL) { > + envent = environ_find(&cmdq->client->environ, "PATH"); > + if (envent != NULL) > + path = envent->value; > + } > + > if (window_pane_spawn( > - new_wp, cmd, shell, cwd, &env, s->tio, &cause) != 0) > + new_wp, cmd, path, shell, cwd, &env, s->tio, &cause) != 0) > goto error; > layout_assign_pane(lc, new_wp); > > diff --git a/session.c b/session.c > index 0730771..19be53b 100644 > --- a/session.c > +++ b/session.c > @@ -84,8 +84,9 @@ session_find_by_id(u_int id) > > /* Create a new session. */ > struct session * > -session_create(const char *name, const char *cmd, int cwd, struct environ > *env, > - struct termios *tio, int idx, u_int sx, u_int sy, char **cause) > +session_create(const char *name, const char *cmd, const char *path, > + int cwd, struct environ *env, struct termios *tio, int idx, u_int sx, > + u_int sy, char **cause) > { > struct session *s; > > @@ -131,7 +132,7 @@ session_create(const char *name, const char *cmd, int > cwd, struct environ *env, > RB_INSERT(sessions, &sessions, s); > > if (cmd != NULL) { > - if (session_new(s, NULL, cmd, cwd, idx, cause) == NULL) { > + if (session_new(s, NULL, cmd, path, cwd, idx, cause) == NULL) { > session_destroy(s); > return (NULL); > } > @@ -225,8 +226,8 @@ session_previous_session(struct session *s) > > /* Create a new window on a session. */ > struct winlink * > -session_new(struct session *s, const char *name, const char *cmd, int cwd, > - int idx, char **cause) > +session_new(struct session *s, const char *name, const char *cmd, > + const char *path, int cwd, int idx, char **cause) > { > struct window *w; > struct winlink *wl; > @@ -249,8 +250,8 @@ session_new(struct session *s, const char *name, const > char *cmd, int cwd, > shell = _PATH_BSHELL; > > hlimit = options_get_number(&s->options, "history-limit"); > - w = window_create(name, cmd, shell, cwd, &env, s->tio, s->sx, s->sy, > - hlimit, cause); > + w = window_create(name, cmd, path, shell, cwd, &env, s->tio, > + s->sx, s->sy, hlimit, cause); > if (w == NULL) { > winlink_remove(&s->windows, wl); > environ_free(&env); > diff --git a/tmux.h b/tmux.h > index 5aac390..c61e221 100644 > --- a/tmux.h > +++ b/tmux.h > @@ -2126,9 +2126,9 @@ void winlink_stack_remove(struct > winlink_stack *, struct winlink *); > int window_index(struct window *, u_int *); > struct window *window_find_by_id(u_int); > struct window *window_create1(u_int, u_int); > -struct window *window_create(const char *, const char *, const char > *, int, > - struct environ *, struct termios *, u_int, u_int, u_int, > - char **); > +struct window *window_create(const char *, const char *, const char *, > + const char *, int, struct environ *, struct termios *, > + u_int, u_int, u_int, char **); > void window_destroy(struct window *); > struct window_pane *window_get_active_at(struct window *, u_int, u_int); > void window_set_active_at(struct window *, u_int, u_int); > @@ -2152,8 +2152,8 @@ struct window_pane *window_pane_create(struct window *, > u_int, u_int, u_int); > void window_pane_destroy(struct window_pane *); > void window_pane_timer_start(struct window_pane *); > int window_pane_spawn(struct window_pane *, const char *, > - const char *, int, struct environ *, struct termios *, > - char **); > + const char *, const char *, int, struct environ *, > + struct termios *, char **); > void window_pane_resize(struct window_pane *, u_int, u_int); > void window_pane_alternate_on(struct window_pane *, > struct grid_cell *, int); > @@ -2289,7 +2289,7 @@ RB_PROTOTYPE(sessions, session, entry, session_cmp); > int session_alive(struct session *); > struct session *session_find(const char *); > struct session *session_find_by_id(u_int); > -struct session *session_create(const char *, const char *, int, > +struct session *session_create(const char *, const char *, const char > *, int, > struct environ *, struct termios *, int, u_int, u_int, > char **); > void session_destroy(struct session *); > @@ -2297,8 +2297,8 @@ int session_check_name(const char *); > void session_update_activity(struct session *); > struct session *session_next_session(struct session *); > struct session *session_previous_session(struct session *); > -struct winlink *session_new(struct session *, const char *, const char > *, int, > - int, char **); > +struct winlink *session_new(struct session *, const char *, const char > *, > + const char *, int, int, char **); > struct winlink *session_attach( > struct session *, struct window *, int, char **); > int session_detach(struct session *, struct winlink *); > diff --git a/window.c b/window.c > index 9a26b90..dedac72 100644 > --- a/window.c > +++ b/window.c > @@ -309,8 +309,8 @@ window_create1(u_int sx, u_int sy) > } > > struct window * > -window_create(const char *name, const char *cmd, const char *shell, > - int cwd, struct environ *env, struct termios *tio, > +window_create(const char *name, const char *cmd, const char *path, > + const char *shell, int cwd, struct environ *env, struct termios *tio, > u_int sx, u_int sy, u_int hlimit, char **cause) > { > struct window *w; > @@ -320,7 +320,8 @@ window_create(const char *name, const char *cmd, const > char *shell, > wp = window_add_pane(w, hlimit); > layout_init(w, wp); > > - if (window_pane_spawn(wp, cmd, shell, cwd, env, tio, cause) != 0) { > + if (window_pane_spawn( > + wp, cmd, path, shell, cwd, env, tio, cause) != 0) { > window_destroy(w); > return (NULL); > } > @@ -810,8 +811,9 @@ window_pane_destroy(struct window_pane *wp) > } > > int > -window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell, > - int cwd, struct environ *env, struct termios *tio, char **cause) > +window_pane_spawn(struct window_pane *wp, const char *cmd, const char *path, > + const char *shell, int cwd, struct environ *env, struct termios *tio, > + char **cause) > { > struct winsize ws; > char *argv0, paneid[16]; > @@ -867,6 +869,9 @@ window_pane_spawn(struct window_pane *wp, const char > *cmd, const char *shell, > > closefrom(STDERR_FILENO + 1); > > + if (path != NULL) > + environ_set(env, "PATH", path); > + > xsnprintf(paneid, sizeof paneid, "%%%u", wp->id); > environ_set(env, "TMUX_PANE", paneid); > environ_push(env); ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/NeoTech _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users