GNOME Bugzilla – Bug 525450
new tabs should start in home directory
Last modified: 2009-07-23 04:27:03 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:
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.
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"?
Related to bug 475981; could be unified.
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.
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...
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.
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.
[ -n "$PS1" -a "$SHLVL" = 2 ] && cd
Put it in your ~/.bash_profile and you don't need those checks even.
.bash_profile is not sourced because it's not a login shell. It has to be .bashrc or equivalent.
Your other idea would probably work, but I think you meant SHLVL = 1.
No, SHLVL=1 is taken by the shell starting gdm, the one that sources ~/.bash_profile, you know :). Just do a echo and see.
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.
Aargh. That's some nasty feature of Ubuntu's sudo which nukes the SHLVL variable.
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.
I thought it was a feature, not a bug needing fixing...
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.
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.
See bug 585047 for a related issue.
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.