gnome-terminal 3.36, which is included in Ubuntu 20.04, added a config
option Preferences -> <profile> -> Command -> Preserve working
directory.

Older versions preserved the directory only when launching a shell, not
when launching a custom command. This behavior was frowned upon by some
folks, understandably.

The change is at https://gitlab.gnome.org/GNOME/gnome-
terminal/-/commit/79b2291 , the two bugtracker entries are linked from
the commit message.

Now, in order for this to work, two more things have to happen:
Whichever application (presumably your shell) is running in the source
window has to set the desired value, and whichever application is
starting up in the new window has to respect it (not intentionally
override it).

For setting: vte-2.91 is intended to do that, see its __vte_osc7()
method. Now there's a chance that some fragment in your shell profile
overrides it. To debug I recommend to manually issue the given escape
sequence and then not give back control to the shell, not to give it a
chance to override from PS1 or PROMPT_COMMAND or so:

  printf "\e]7;file:/etc\e\\" ; sleep 1000

A newly opened tab should be in /etc now. If this fixes the problem then
try it without the sleep. If that still fixes then your shell just
doesn't emit it. If removing the sleep breaks it again then there's
something in your prompt overriding the value.

To debug the other side: Set up a custom command of "sleep 2000", open a
new window, from another terminal locate the pid of this sleep, and
check its working directory at /proc/<pid>/cwd. If this is set
correctly, yet it doesn't work your shell or custom command, then it's
that command intentionally switching to some other directory.

-- 
You received this bug notification because you are a member of Desktop
Packages, which is subscribed to gnome-terminal in Ubuntu.
https://bugs.launchpad.net/bugs/1609342

Title:
  Gnome-terminal sets directory to HOME for ctrl-shift-n and custom
  shell command

Status in gnome-terminal package in Ubuntu:
  Confirmed

Bug description:
  With Ubuntu 14.04 I could Ctrl-Shift-N in my gnome-terminal and
  another terminal window came up with the same working directory. When
  I upgraded to 16.04.1, the new terminal window now always uses $HOME
  as working directory. I want the 14.04 behavior.

  This has nothing to do with sourcing /etc/profile.d/vte.sh. Fish does
  this correctly as I can observe directory changes in the title bar. If
  I uncheck the custom command box in my gnome-terminal profile, the new
  terminal window correctly uses the current directory. However, it uses
  my system default shell: bash.

  For some reason gnome-terminal does not set the working directory if I
  use a custom command.

  ProblemType: Bug
  DistroRelease: Ubuntu 16.04
  Package: gnome-terminal 3.18.3-1ubuntu1
  ProcVersionSignature: Ubuntu 4.4.0-31.50-generic 4.4.13
  Uname: Linux 4.4.0-31-generic x86_64
  NonfreeKernelModules: openafs nvidia
  ApportVersion: 2.20.1-0ubuntu2.1
  Architecture: amd64
  CurrentDesktop: Unity
  Date: Wed Aug  3 12:32:22 2016
  InstallationDate: Installed on 2013-02-13 (1266 days ago)
  InstallationMedia: Ubuntu 12.10 "Quantal Quetzal" - Release amd64 (20121017.5)
  JournalErrors:
   Error: command ['journalctl', '-b', '--priority=warning', '--lines=1000'] 
failed with exit code 1: Hint: You are currently not seeing messages from other 
users and the system.
         Users in the 'systemd-journal' group can see all messages. Pass -q to
         turn off this notice.
   No journal files were opened due to insufficient permissions.
  SourcePackage: gnome-terminal
  UpgradeStatus: Upgraded to xenial on 2016-08-01 (1 days ago)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gnome-terminal/+bug/1609342/+subscriptions

-- 
Mailing list: https://launchpad.net/~desktop-packages
Post to     : desktop-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~desktop-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to