From 82f0c859a2bcdfac79d242793b7720b74d62d04b Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 16 Feb 2019 11:42:08 +0000 Subject: [PATCH] Use starting client cwd in config file, GitHub issue 1606. --- cfg.c | 3 ++- server-client.c | 2 ++ tmux.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cfg.c b/cfg.c index a448c4b1..9cbb9c2a 100644 --- a/cfg.c +++ b/cfg.c @@ -38,6 +38,7 @@ struct cfg_cond { }; TAILQ_HEAD(cfg_conds, cfg_cond); +struct client *cfg_client; static char *cfg_file; int cfg_finished; static char **cfg_causes; @@ -95,7 +96,7 @@ start_cfg(void) * command queue is currently empty and our callback will be at the * front - we need to get in before MSG_COMMAND. */ - c = TAILQ_FIRST(&clients); + cfg_client = c = TAILQ_FIRST(&clients); if (c != NULL) { cfg_item = cmdq_get_callback(cfg_client_done, NULL); cmdq_append(c, cfg_item); diff --git a/server-client.c b/server-client.c index 0e105d7c..bf69a981 100644 --- a/server-client.c +++ b/server-client.c @@ -1982,6 +1982,8 @@ server_client_get_cwd(struct client *c, struct session *s) { const char *home; + if (!cfg_finished && cfg_client != NULL) + return (cfg_client->cwd); if (c != NULL && c->session == NULL && c->cwd != NULL) return (c->cwd); if (s != NULL && s->cwd != NULL) diff --git a/tmux.h b/tmux.h index b263b371..44d5fbcc 100644 --- a/tmux.h +++ b/tmux.h @@ -1527,6 +1527,7 @@ void proc_toggle_log(struct tmuxproc *); /* cfg.c */ extern int cfg_finished; +extern struct client *cfg_client; void start_cfg(void); int load_cfg(const char *, struct client *, struct cmdq_item *, int); void set_cfg_file(const char *);