aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd-split-window.c1
-rw-r--r--format.c3
-rw-r--r--osdep-linux.c4
-rw-r--r--osdep-openbsd.c24
-rw-r--r--tmux.11
-rw-r--r--tmux.h6
6 files changed, 31 insertions, 8 deletions
diff --git a/cmd-split-window.c b/cmd-split-window.c
index 506c8033..4bb069f0 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -20,7 +20,6 @@
#include <errno.h>
#include <fcntl.h>
-#include <paths.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
diff --git a/format.c b/format.c
index 450e15f3..1e89b2d2 100644
--- a/format.c
+++ b/format.c
@@ -523,6 +523,7 @@ format_window_pane(struct format_tree *ft, struct window_pane *wp)
struct grid_line *gl;
unsigned long long size;
u_int i, idx;
+ const char *cmd;
char *cmd;
size = 0;
@@ -555,6 +556,8 @@ format_window_pane(struct format_tree *ft, struct window_pane *wp)
format_add(ft, "pane_pid", "%ld", (long) wp->pid);
if (wp->cmd != NULL)
format_add(ft, "pane_start_command", "%s", wp->cmd);
+ if ((cwd = osdep_get_cwd(wp->fd)) != NULL)
+ format_add(ft, "pane_current_path", "%s", cwd);
if ((cmd = format_get_command(wp)) != NULL) {
format_add(ft, "pane_current_command", "%s", cmd);
free(cmd);
diff --git a/osdep-linux.c b/osdep-linux.c
index 20a76611..ccac2670 100644
--- a/osdep-linux.c
+++ b/osdep-linux.c
@@ -26,10 +26,6 @@
#include "tmux.h"
-char *osdep_get_name(int, char *);
-char *osdep_get_cwd(int);
-struct event_base *osdep_event_init(void);
-
char *
osdep_get_name(int fd, unused char *tty)
{
diff --git a/osdep-openbsd.c b/osdep-openbsd.c
index c61d90e7..0a4c1445 100644
--- a/osdep-openbsd.c
+++ b/osdep-openbsd.c
@@ -37,7 +37,9 @@
((p)->p_stat == SSTOP || (p)->p_stat == SZOMB || (p)->p_stat == SDEAD)
struct kinfo_proc *cmp_procs(struct kinfo_proc *, struct kinfo_proc *);
-char *get_proc_name(int, char *);
+char *osdep_get_name(int, char *);
+char *osdep_get_cwd(int);
+struct event_base *osdep_event_init(void);
struct kinfo_proc *
cmp_procs(struct kinfo_proc *p1, struct kinfo_proc *p2)
@@ -132,3 +134,23 @@ error:
free(buf);
return (NULL);
}
+
+char *
+osdep_get_cwd(int fd)
+{
+ int name[] = { CTL_KERN, KERN_PROC_CWD, 0 };
+ static char path[MAXPATHLEN];
+ size_t pathlen = sizeof path;
+
+ if ((name[2] = tcgetpgrp(fd)) == -1)
+ return (NULL);
+ if (sysctl(name, 3, path, &pathlen, NULL, 0) != 0)
+ return (NULL);
+ return (path);
+}
+
+struct event_base *
+osdep_event_init(void)
+{
+ return (event_init());
+}
diff --git a/tmux.1 b/tmux.1
index 56cb3f8f..1eb02feb 100644
--- a/tmux.1
+++ b/tmux.1
@@ -3072,6 +3072,7 @@ The following variables are available, where appropriate:
.It Li "mouse_utf8_flag" Ta "" Ta "Pane mouse UTF-8 flag"
.It Li "pane_active" Ta "" Ta "1 if active pane"
.It Li "pane_current_command" Ta "" Ta "Current command if available"
+.It Li "pane_current_path" Ta "" Ta "Current path if available"
.It Li "pane_dead" Ta "" Ta "1 if pane is dead"
.It Li "pane_height" Ta "" Ta "Height of pane"
.It Li "pane_id" Ta "#D" Ta "Unique pane ID"
diff --git a/tmux.h b/tmux.h
index 3a298840..84ad1643 100644
--- a/tmux.h
+++ b/tmux.h
@@ -2308,8 +2308,10 @@ int utf8_append(struct utf8_data *, u_char);
u_int utf8_combine(const struct utf8_data *);
u_int utf8_split2(u_int, u_char *);
-/* procname.c */
-char *get_proc_name(int, char *);
+/* osdep-*.c */
+char *osdep_get_name(int, char *);
+char *osdep_get_cwd(int);
+struct event_base *osdep_event_init(void);
/* log.c */
void log_open(int, const char *);