diff options
author | nicm <nicm> | 2015-09-01 10:10:59 +0000 |
---|---|---|
committer | nicm <nicm> | 2015-09-01 10:10:59 +0000 |
commit | 952ba846111fb91d9882846a4061955262f34212 (patch) | |
tree | eb22a9459bcf676b7d0f152330dddc50623adf9b /cfg.c | |
parent | 83157c02d6935d3ea4dcf6e39d6a531849a775d6 (diff) |
Work out config file when needed not at startup.
Diffstat (limited to 'cfg.c')
-rw-r--r-- | cfg.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -28,6 +28,7 @@ #include "tmux.h" +char *cfg_file; struct cmd_q *cfg_cmd_q; int cfg_finished; int cfg_references; @@ -38,9 +39,17 @@ struct client *cfg_client; void cfg_default_done(struct cmd_q *); void +set_cfg_file(const char *path) +{ + free(cfg_file); + cfg_file = xstrdup(path); +} + +void start_cfg(void) { - char *cause = NULL; + char *cause = NULL; + const char *home; cfg_cmd_q = cmdq_new(NULL); cfg_cmd_q->emptyfn = cfg_default_done; @@ -58,6 +67,13 @@ start_cfg(void) } else if (errno != ENOENT) cfg_add_cause("%s: %s", TMUX_CONF, strerror(errno)); + if (cfg_file == NULL && (home = find_home()) != NULL) { + xasprintf(&cfg_file, "%s/.tmux.conf", home); + if (access(cfg_file, R_OK) != 0 && errno == ENOENT) { + free(cfg_file); + cfg_file = NULL; + } + } if (cfg_file != NULL && load_cfg(cfg_file, cfg_cmd_q, &cause) == -1) cfg_add_cause("%s: %s", cfg_file, cause); free(cause); |