aboutsummaryrefslogtreecommitdiff
path: root/tmux.c
diff options
context:
space:
mode:
authornicm <nicm>2015-07-20 15:50:04 +0000
committernicm <nicm>2015-07-20 15:50:04 +0000
commit92af3766ecc456bd8ade8fe5746d27f4557fdaa8 (patch)
tree371174df95c9f8b2bd7e515505325853c88040d0 /tmux.c
parentd4ce210713cc907fc69497c51cf9b64d2f414ca4 (diff)
downloadrtmux-92af3766ecc456bd8ade8fe5746d27f4557fdaa8.tar.gz
rtmux-92af3766ecc456bd8ade8fe5746d27f4557fdaa8.tar.bz2
rtmux-92af3766ecc456bd8ade8fe5746d27f4557fdaa8.zip
Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.
Diffstat (limited to 'tmux.c')
-rw-r--r--tmux.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/tmux.c b/tmux.c
index 878180a7..a3481461 100644
--- a/tmux.c
+++ b/tmux.c
@@ -198,10 +198,27 @@ shell_exec(const char *shell, const char *shellcmd)
fatal("execl failed");
}
+const char*
+find_home(void)
+{
+ struct passwd *pw;
+ const char *home;
+
+ home = getenv("HOME");
+ if (home == NULL || *home == '\0') {
+ pw = getpwuid(getuid());
+ if (pw != NULL)
+ home = pw->pw_dir;
+ else
+ home = NULL;
+ }
+
+ return home;
+}
+
int
main(int argc, char **argv)
{
- struct passwd *pw;
char *s, *path, *label, **var, tmp[PATH_MAX];
char in[256];
const char *home;
@@ -320,14 +337,7 @@ main(int argc, char **argv)
/* Locate the configuration file. */
if (cfg_file == NULL) {
- home = getenv("HOME");
- if (home == NULL || *home == '\0') {
- pw = getpwuid(getuid());
- if (pw != NULL)
- home = pw->pw_dir;
- else
- home = NULL;
- }
+ home = find_home();
if (home != NULL) {
xasprintf(&cfg_file, "%s/.tmux.conf", home);
if (access(cfg_file, R_OK) != 0 && errno == ENOENT) {