After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 525450 - new tabs should start in home directory
new tabs should start in home directory
Status: RESOLVED WONTFIX
Product: gnome-terminal
Classification: Core
Component: general
2.18.x
Other All
: Normal minor
: ---
Assigned To: GNOME Terminal Maintainers
GNOME Terminal Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-03-31 22:10 UTC by Mikel Ward
Modified: 2009-07-23 04:27 UTC
See Also:
GNOME target: ---
GNOME version: 2.19/2.20



Description Mikel Ward 2008-03-31 22:10:01 UTC
Please describe the problem:
When I open a new tab, the new shell inherits the working directory from the current tab.

This is unlike most programs, only works for local shells, and is seldom what I want.  I end up having to do a "cd" for every new tab before I can think straight.

I think this is undesirable and should be removed, but if not, please at least allow me to disable it.

The original feature request was bug 89029, closed in 2003.

Steps to reproduce:


Actual results:


Expected results:


Does this happen every time?


Other information:
Comment 1 Behdad Esfahbod 2008-03-31 23:32:36 UTC
I object to removing this feature.  My workflow is that when I'm working on something in a directory and I need to quickly do something else, I open a new window/tab, and it's great that it opens up in the same dir.  If I don't want that behavior, a simple "cd" does it.  On the other hand, if we remove this feature, there's no easy way to achieve it by way of a simple command.
Comment 2 Mikel Ward 2008-03-31 23:49:02 UTC
Well, it could actually populate the environment with OLDPWD and you could do "cd -", but I wouldn't advocate that.

My argument is that only some people find this useful, and you are making the lives of other uses harder.  Why should I even have to run "cd"?
Comment 3 Christian Persch 2008-06-15 20:41:06 UTC
Related to bug 475981; could be unified.
Comment 4 Josh Triplett 2008-11-04 07:16:39 UTC
I *love* this feature of gnome-terminal, and I really don't want it to go away.  I find it an incredible time-saver.

However, I also think having the option to turn it off makes sense.
Comment 5 Mariano Suárez-Alvarez 2008-11-07 19:01:38 UTC
Isn't typing 'cd' as the tab shows up a way to turn the behaviour off?
An alternative is to add a 'cd ~' to the appropriate shell configuration file, I guess. 

The rationale for starting in the current directory is that tha is what you'd get if you ran 'xterm' in the old shell, or 'gnome-terminal': making new tabs open in the home directory makes opening a window using the GUI and opening a window using the command line do two different things...
Comment 6 Markus Amalthea Magnuson 2008-11-15 13:43:52 UTC
I think it should be the power users who has to tinker with their profile files to achieve this behaviour, and everyone else getting their home folder by default, rather than the other way around. In other words, make it a hidden option and default to the home folder, which I think is appropriate for a larger number of users.
Comment 7 Mikel Ward 2008-12-09 20:54:03 UTC
Putting "cd" or "cd ~" in the shell configuration file is not a valid workaround.  It has other side effects.  For example, if I put it in .bashrc, open a new tab, cd somewhere, then run either "bash" or "sudo -s", it cds, when the usual behavior is that it says where I cd'd to.

Mariano, that rationale doesn't make any sense.  If you ran "xterm" from a terminal window, it would spawn a new window, not a new tab.  They're completely different things.

Please, please, let me disable this.
Comment 8 Behdad Esfahbod 2008-12-09 21:01:26 UTC
[ -n "$PS1" -a "$SHLVL" = 2 ] && cd
Comment 9 Behdad Esfahbod 2008-12-09 21:07:09 UTC
Put it in your ~/.bash_profile and you don't need those checks even.
Comment 10 Mikel Ward 2008-12-09 21:45:00 UTC
.bash_profile is not sourced because it's not a login shell.  It has to be .bashrc or equivalent.
Comment 11 Mikel Ward 2008-12-09 21:50:44 UTC
Your other idea would probably work, but I think you meant SHLVL = 1.
Comment 12 Behdad Esfahbod 2008-12-09 21:53:03 UTC
No, SHLVL=1 is taken by the shell starting gdm, the one that sources ~/.bash_profile, you know :).

Just do a echo and see.
Comment 13 Mikel Ward 2008-12-09 21:59:29 UTC
I did. :-)

For me at least:
$ echo $SHLVL
1
$ bash
$ echo $SHLVL
2
$ exit
$ sudo -s
# echo $SHLVL
1

So it still isn't a valid workaround.

And I say _workaround_! ;-)

I guess the next step is some monstrosity like

[ $SHLVL -eq 1 ] && [ $UID -ne 0 ] && cd

Which I guess will work in my case, since I don't intend to log in to X as root.
Comment 14 Mikel Ward 2008-12-09 22:05:42 UTC
Aargh.  That's some nasty feature of Ubuntu's sudo which nukes the SHLVL variable.
Comment 15 Brian Cameron 2009-03-12 01:05:47 UTC
I notice that running the latest gnome-terminal 2.25.91 that new tabs always seem
to go back to the users $HOME directory.  So is this bug fixed, or is it a bug that gnome-terminal now works this way?

In other words if I run gnome-terminal, cd into /tmp and then open a new tab, the new tab starts with PWD as my $HOME directory.  
Comment 16 Mariano Suárez-Alvarez 2009-03-12 03:15:54 UTC
I thought it was a feature, not a bug needing fixing...
Comment 17 Christian Persch 2009-03-12 14:46:53 UTC
Re comment 15: this works as expected here, cd /tmp + open new tab => new tab starts in /tmp. Can you check what terminal_screen_get_current_dir() returns? If it's incorrect, please open a new bug, since it has nothing to do with this bug report as defined by comment 0.
Comment 18 Brian Cameron 2009-03-13 03:42:44 UTC
Yes, this is a different bug.  I filed bug #575184 to report the new issue.  Sorry
for cluttering up this bug - I didn't realize this was a Solaris specific issue.
Comment 19 Josh Triplett 2009-07-23 04:11:34 UTC
See bug 585047 for a related issue.
Comment 20 Josh Triplett 2009-07-23 04:27:03 UTC
It sounds to me like many people, including a gnome-terminal developer, object to removing the gnome-terminal feature which starts new tabs in the working directory of the current tab.  Based on that, I'll go out on a limb and resolve this as WONTFIX.

TThose who don't like this behavior of gnome-terminal can easily configure gnome-terminal to avoid it without needing to add a hack to their shell startup scripts. Just open gnome-terminal's profile preferences, go to the "Title and Command" tab, check "Run a custom command instead of my shell", and specify this as the command:

sh -c 'cd ; exec $SHELL'

I just tested this, and it works as expected: new tabs end up in $HOME, regardless of the working directory of the current tab.

If, despite that configuration option, someone still wants a dedicated option in the profile preferences to start in $HOME or perhaps an arbitrary specified directory, that should probably become a separate feature request.