From 2ce1b9955ce54db46fd2a09dcf04245f93197607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 29 Aug 2021 18:36:58 +0200 Subject: [PATCH 1/3] Signal CWD change to terminal via OSC-7 Closes #1147 --- src/nnn.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/nnn.c b/src/nnn.c index 146acbbbe..fbadd240f 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -6424,7 +6424,7 @@ static bool browse(char *ipath, const char *session, int pkey) char newpath[PATH_MAX] __attribute__ ((aligned)), rundir[PATH_MAX] __attribute__ ((aligned)), runfile[NAME_MAX + 1] __attribute__ ((aligned)); - char *path, *lastdir, *lastname, *dir, *tmp; + char *path, *lastdir, *lastname, *dir, *tmp, hostname[_POSIX_HOST_NAME_MAX]; pEntry pent; enum action sel; struct stat sb; @@ -6501,6 +6501,11 @@ static bool browse(char *ipath, const char *session, int pkey) setdirwatch(); } + /* Signal CWD change to terminal */ + gethostname(hostname, sizeof(hostname)); + printf("\033]7;file://%s%s\033\\", hostname, path); + fflush(stdout); + #ifndef NOX11 if (cfg.x11 && !g_state.picker) { /* Set terminal window title */ From 03754d61f0d78ab296f6fc7fb1a66e8a814c6610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 29 Aug 2021 19:35:09 +0200 Subject: [PATCH 2/3] Make OSC-7 emission gated by NOX11 --- src/nnn.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/nnn.c b/src/nnn.c index fbadd240f..6bba048f3 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -6501,13 +6501,12 @@ static bool browse(char *ipath, const char *session, int pkey) setdirwatch(); } - /* Signal CWD change to terminal */ - gethostname(hostname, sizeof(hostname)); - printf("\033]7;file://%s%s\033\\", hostname, path); - fflush(stdout); - #ifndef NOX11 if (cfg.x11 && !g_state.picker) { + /* Signal CWD change to terminal */ + gethostname(hostname, sizeof(hostname)); + printf("\033]7;file://%s%s\033\\", hostname, path); + /* Set terminal window title */ r = set_tilde_in_path(path); From 3f1a2a7b344412c85bf843463ae3907b3f0f5928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 29 Aug 2021 20:27:02 +0200 Subject: [PATCH 3/3] Use newpath variable in gethostname() --- src/nnn.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nnn.c b/src/nnn.c index 6bba048f3..bb678fb4d 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -6424,7 +6424,7 @@ static bool browse(char *ipath, const char *session, int pkey) char newpath[PATH_MAX] __attribute__ ((aligned)), rundir[PATH_MAX] __attribute__ ((aligned)), runfile[NAME_MAX + 1] __attribute__ ((aligned)); - char *path, *lastdir, *lastname, *dir, *tmp, hostname[_POSIX_HOST_NAME_MAX]; + char *path, *lastdir, *lastname, *dir, *tmp; pEntry pent; enum action sel; struct stat sb; @@ -6504,8 +6504,8 @@ static bool browse(char *ipath, const char *session, int pkey) #ifndef NOX11 if (cfg.x11 && !g_state.picker) { /* Signal CWD change to terminal */ - gethostname(hostname, sizeof(hostname)); - printf("\033]7;file://%s%s\033\\", hostname, path); + gethostname(newpath, sizeof(newpath)); + printf("\033]7;file://%s%s\033\\", newpath, path); /* Set terminal window title */ r = set_tilde_in_path(path);