diff --git a/doc/man/mc.1.in b/doc/man/mc.1.in
index da3c9720c..3d152451f 100644
a
|
b
|
unintentionally becomes more difficult. The default selection in the |
1967 | 1967 | confirmation dialogs for deletion changes from "Yes" to "No". |
1968 | 1968 | This option is disabled by default. |
1969 | 1969 | .PP |
| 1970 | .I Auto cd new terminal. |
| 1971 | If this option is enabled, mc tells its current directory to the terminal. |
| 1972 | Some graphical terminal emulators use this information to open new windows |
| 1973 | or tabs in that directory. |
| 1974 | .PP |
1970 | 1975 | .I Auto save setup. |
1971 | 1976 | If this option is enabled, when you exit Midnight Commander, the |
1972 | 1977 | configurable options of Midnight Commander are saved in the |
diff --git a/src/execute.c b/src/execute.c
index 5bb017f00..f6544f26a 100644
a
|
b
|
do_executev (const char *shell, int flags, char *const argv[]) |
371 | 371 | { |
372 | 372 | update_panels (UP_OPTIMIZE, UP_KEEPSEL); |
373 | 373 | update_xterm_title_path (); |
| 374 | update_terminal_cwd (); |
374 | 375 | } |
375 | 376 | |
376 | 377 | do_refresh (); |
… |
… |
toggle_panels (void) |
551 | 552 | { |
552 | 553 | update_panels (UP_OPTIMIZE, UP_KEEPSEL); |
553 | 554 | update_xterm_title_path (); |
| 555 | update_terminal_cwd (); |
554 | 556 | } |
555 | 557 | |
556 | 558 | if (was_sigwinch != 0 || mc_global.tty.winch_flag != 0) |
diff --git a/src/filemanager/boxes.c b/src/filemanager/boxes.c
index 90dc6e052..0f164d5ce 100644
a
|
b
|
configure_box (void) |
546 | 546 | QUICK_CHECKBOX (N_("Rotating d&ash"), &nice_rotating_dash, NULL), |
547 | 547 | QUICK_CHECKBOX (N_("Cd follows lin&ks"), &mc_global.vfs.cd_symlinks, NULL), |
548 | 548 | QUICK_CHECKBOX (N_("Sa&fe delete"), &safe_delete, NULL), |
| 549 | QUICK_CHECKBOX (N_("Auto cd new terminal"), &auto_cd_new_terminal, NULL), // TODO: shortcut key! |
549 | 550 | QUICK_CHECKBOX (N_("A&uto save setup"), &auto_save_setup, NULL), |
550 | 551 | QUICK_SEPARATOR (FALSE), |
551 | 552 | QUICK_SEPARATOR (FALSE), |
552 | | QUICK_SEPARATOR (FALSE), |
553 | 553 | QUICK_STOP_GROUPBOX, |
554 | 554 | QUICK_STOP_COLUMNS, |
555 | 555 | QUICK_BUTTONS_OK_CANCEL, |
diff --git a/src/filemanager/layout.c b/src/filemanager/layout.c
index 10f06643c..d9194ea11 100644
a
|
b
|
setup_panels (void) |
791 | 791 | widget_set_size (WIDGET (the_hint), 0, 0, 0, 0); |
792 | 792 | |
793 | 793 | update_xterm_title_path (); |
| 794 | update_terminal_cwd (); |
794 | 795 | } |
795 | 796 | |
796 | 797 | /* --------------------------------------------------------------------------------------------- */ |
… |
… |
update_xterm_title_path (void) |
1437 | 1438 | } |
1438 | 1439 | |
1439 | 1440 | /* --------------------------------------------------------------------------------------------- */ |
| 1441 | |
| 1442 | /** Tell the current directory to the terminal so it can open new tabs there */ |
| 1443 | void |
| 1444 | update_terminal_cwd (void) |
| 1445 | { |
| 1446 | if (mc_global.tty.xterm_flag && auto_cd_new_terminal && vfs_current_is_local ()) |
| 1447 | { |
| 1448 | const gchar *host; |
| 1449 | char *path; |
| 1450 | int pathlen, i; |
| 1451 | unsigned char c; |
| 1452 | |
| 1453 | host = g_get_host_name (); |
| 1454 | path = vfs_path_to_str_flags (current_panel->cwd_vpath, 0, VPF_NONE); |
| 1455 | pathlen = strlen (path); |
| 1456 | |
| 1457 | fprintf (stdout, "\33]7;file://%s", host); |
| 1458 | for (i = 0; i < pathlen; i++) { |
| 1459 | c = path[i]; |
| 1460 | if ((c >= '0' && c <= '9') || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z') || index("/_.-()~", c) != NULL) |
| 1461 | fprintf(stdout, "%c", c); |
| 1462 | else |
| 1463 | fprintf(stdout, "%%%02X", c); |
| 1464 | } |
| 1465 | fprintf (stdout, "\7"); |
| 1466 | (void) fflush (stdout); |
| 1467 | g_free (path); |
| 1468 | } |
| 1469 | } |
| 1470 | |
| 1471 | /* --------------------------------------------------------------------------------------------- */ |
diff --git a/src/filemanager/layout.h b/src/filemanager/layout.h
index a8658382a..5d281c024 100644
a
|
b
|
int load_prompt (int fd, void *unused); |
90 | 90 | #endif |
91 | 91 | |
92 | 92 | void update_xterm_title_path (void); |
| 93 | void update_terminal_cwd (void); |
93 | 94 | |
94 | 95 | void title_path_prepare (char **path, char **login); |
95 | 96 | |
diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c
index 039ec7ccc..9107d5312 100644
a
|
b
|
_do_panel_cd (WPanel * panel, const vfs_path_t * new_dir_vpath, enum cd_enum cd_ |
3311 | 3311 | load_hint (FALSE); |
3312 | 3312 | panel->dirty = 1; |
3313 | 3313 | update_xterm_title_path (); |
| 3314 | update_terminal_cwd (); |
3314 | 3315 | |
3315 | 3316 | vfs_path_free (olddir_vpath); |
3316 | 3317 | |
… |
… |
panel_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d |
3691 | 3692 | subshell_chdir (panel->cwd_vpath); |
3692 | 3693 | |
3693 | 3694 | update_xterm_title_path (); |
| 3695 | update_terminal_cwd (); |
3694 | 3696 | select_item (panel); |
3695 | 3697 | |
3696 | 3698 | bb = find_buttonbar (w->owner); |
diff --git a/src/setup.c b/src/setup.c
index 430075ced..f0e0d7788 100644
a
|
b
|
gboolean confirm_view_dir = FALSE; |
114 | 114 | /* Ask file name before start the editor */ |
115 | 115 | gboolean editor_ask_filename_before_edit = FALSE; |
116 | 116 | |
| 117 | /* Tell cwd to the terminal so it can open new tabs there */ |
| 118 | gboolean auto_cd_new_terminal = 0; |
| 119 | |
117 | 120 | panel_view_mode_t startup_left_mode; |
118 | 121 | panel_view_mode_t startup_right_mode; |
119 | 122 | |
… |
… |
static const struct |
352 | 355 | { "mcview_remember_file_position", &mcview_remember_file_position }, |
353 | 356 | { "auto_fill_mkdir_name", &auto_fill_mkdir_name }, |
354 | 357 | { "copymove_persistent_attr", ©move_persistent_attr }, |
| 358 | { "auto_cd_new_terminal", &auto_cd_new_terminal }, |
355 | 359 | { NULL, NULL } |
356 | 360 | }; |
357 | 361 | |
diff --git a/src/setup.h b/src/setup.h
index b483d7da9..13729fe06 100644
a
|
b
|
extern gboolean output_starts_shell; |
98 | 98 | extern gboolean use_file_to_check_type; |
99 | 99 | extern gboolean file_op_compute_totals; |
100 | 100 | extern gboolean editor_ask_filename_before_edit; |
| 101 | extern gboolean auto_cd_new_terminal; |
101 | 102 | |
102 | 103 | extern panels_options_t panels_options; |
103 | 104 | |