diff options
-rw-r--r-- | terminal.vala | 21 | ||||
-rw-r--r-- | weltschmerz.1 | 20 |
2 files changed, 23 insertions, 18 deletions
diff --git a/terminal.vala b/terminal.vala index 47c33bc..1005996 100644 --- a/terminal.vala +++ b/terminal.vala @@ -40,6 +40,8 @@ class Terminal : Gtk.Overlay { Gtk.MenuItem[] open_with_items = {}; + Pid child_pid; + bool has_search; bool overlay_scrolling_env_override; string url_match; @@ -83,7 +85,7 @@ class Terminal : Gtk.Overlay { argv = { Utils.get_shell() }; } - vte.spawn_sync(DEFAULT, null, argv, null, SEARCH_PATH, null, null, null); + vte.spawn_sync(DEFAULT, null, argv, null, SEARCH_PATH, null, out child_pid, null); } catch (Error e) { error(e.message); } @@ -368,7 +370,7 @@ class Terminal : Gtk.Overlay { adjust_font_scale(vte.get_font_scale() / FONT_SCALE_FACTOR); } - string? get_local_directory_path() { + string? get_osc7_path() { var uri = vte.get_current_directory_uri(); if (uri == null) return null; @@ -392,6 +394,13 @@ class Terminal : Gtk.Overlay { return path; } + string? get_cwd() { + string? osc7_path = get_osc7_path(); + if (osc7_path != null) + return osc7_path; + return Posix.realpath("/proc/%i/cwd".printf(child_pid)); + } + void spawn_process(string? cwd, string[] argv) { Pid child; @@ -407,7 +416,7 @@ class Terminal : Gtk.Overlay { [GtkCallback] void open_terminal() { - var cwd = get_local_directory_path(); + var cwd = get_cwd(); if (cwd == null) return; spawn_process(cwd, {PROGRAM_NAME}); @@ -415,7 +424,7 @@ class Terminal : Gtk.Overlay { [GtkCallback] void open_directory() { - var cwd = get_local_directory_path(); + var cwd = get_cwd(); if (cwd == null) return; @@ -449,8 +458,8 @@ class Terminal : Gtk.Overlay { } else { copy_item_text.set_sensitive(vte.get_has_selection()); copy_item_html.set_sensitive(vte.get_has_selection()); - open_terminal_item.set_sensitive(get_local_directory_path() != null); - open_directory_item.set_sensitive(get_local_directory_path() != null); + open_terminal_item.set_sensitive(get_cwd() != null); + open_directory_item.set_sensitive(get_cwd() != null); standard_context_menu.popup_at_pointer(event); } return true; diff --git a/weltschmerz.1 b/weltschmerz.1 index 6b64184..2e0a2fb 100644 --- a/weltschmerz.1 +++ b/weltschmerz.1 @@ -45,19 +45,15 @@ and It can be reset to its default value with .Sy CTRL + 0 . .Pp -The program's current directory can be opened in the default file manager with -.Sy CTRL + Shift + O . -Note that -.Nm -relies on proper support of OSC 7 to do this. -If the child program (such as the shell or an editor) does not send OSC 7, -this feature will not work. -.Pp -A new terminal window can likewise be opened in the program's current directory with -.Sy CTRL + Shift + T . -The limitations of +The default file manager can be opened in the current directory with .Sy CTRL + Shift + O -also apply here. +and a new terminal window with +.Sy CTRL + Shift + T . +By default OSC 7 path is used as the current directory, but if OSC 7 path is not +set to a valid local path and the platform provides a Linux-style procfs at +.Pa /proc , +.Nm +will use the child process's working directory instead. .Sh SEARCH OVERLAY The search overlay can be opened by pressing .Sy CTRL + Shift + F . |