diff --git a/src/execute.c b/src/execute.c index 21095a20d..ad60ef96b 100644 --- a/src/execute.c +++ b/src/execute.c @@ -373,6 +373,7 @@ do_executev (const char *shell, int flags, char *const argv[]) { update_panels (UP_OPTIMIZE, UP_KEEPSEL); update_xterm_title_path (); + update_terminal_cwd (); } do_refresh (); @@ -567,6 +568,7 @@ toggle_subshell (void) { update_panels (UP_OPTIMIZE, UP_KEEPSEL); update_xterm_title_path (); + update_terminal_cwd (); } if (was_sigwinch != 0 || tty_got_winch ()) diff --git a/src/filemanager/layout.c b/src/filemanager/layout.c index 11607720d..de326f375 100644 --- a/src/filemanager/layout.c +++ b/src/filemanager/layout.c @@ -913,6 +913,7 @@ setup_panels (void) widget_set_visibility (WIDGET (the_bar), mc_global.keybar_visible); update_xterm_title_path (); + update_terminal_cwd (); /* unlock */ if (active) @@ -1567,7 +1568,7 @@ update_xterm_title_path (void) g_free (login); g_free (path); - fprintf (stdout, "\33]0;%s\7", str_term_form (p)); + fprintf (stdout, ESC_STR "]0;%s" ESC_STR "\\", str_term_form (p)); g_free (p); if (!mc_global.tty.alternate_plus_minus) @@ -1577,3 +1578,26 @@ update_xterm_title_path (void) } /* --------------------------------------------------------------------------------------------- */ + +/** Tell the current directory to the terminal so it can open new tabs there */ +void +update_terminal_cwd (void) +{ + if (mc_global.tty.xterm_flag && vfs_current_is_local ()) + { + const gchar *host; + char *path, *path_uri; + + host = g_get_host_name (); + path = vfs_path_to_str_flags (current_panel->cwd_vpath, 0, VPF_NONE); + path_uri = g_uri_escape_string (path, "/", FALSE); + + fprintf (stdout, ESC_STR "]7;file://%s%s" ESC_STR "\\", host, path_uri); + (void) fflush (stdout); + + g_free (path_uri); + g_free (path); + } +} + +/* --------------------------------------------------------------------------------------------- */ diff --git a/src/filemanager/layout.h b/src/filemanager/layout.h index 2566cfa32..685f2c371 100644 --- a/src/filemanager/layout.h +++ b/src/filemanager/layout.h @@ -90,6 +90,7 @@ int load_prompt (int fd, void *unused); #endif void update_xterm_title_path (void); +void update_terminal_cwd (void); void title_path_prepare (char **path, char **login); diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c index b1174c0bf..f14fd38d7 100644 --- a/src/filemanager/panel.c +++ b/src/filemanager/panel.c @@ -3436,6 +3436,7 @@ panel_do_cd_int (WPanel * panel, const vfs_path_t * new_dir_vpath, enum cd_enum load_hint (FALSE); panel->dirty = TRUE; update_xterm_title_path (); + update_terminal_cwd (); vfs_path_free (olddir_vpath, TRUE); @@ -3823,6 +3824,7 @@ panel_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d subshell_chdir (panel->cwd_vpath); update_xterm_title_path (); + update_terminal_cwd (); select_item (panel); bb = buttonbar_find (h);