Debian – How to preserve path in a new tab in the gnome terminal

debian-wheezygnometerminal

At work I am using Ubuntu GNU/Linux 14.04. When I open a new tab in the gnome terminal, the working directory of the new shell is the same as in the terminal where I have pressed CTRL-SHIFT-T.

At home I have Debian Wheezy, and here the default behaviour is to open the new shell in my home directory. I cannot find any documentation as to how to change this behaviour: I would like to have the Ubuntu behaviour on Debian.

Is this feature configurable at all or is it hard-coded, with different versions providing different behaviours? I have read the documentation and searched for a question on stack exchange but I could not find any information.

EDIT

I have looked into my .bashrc and indeed there was some complicated setup that ended up changing / resetting the path. So, I have come one step further but I still have one problem, which is illustrated in this still unanswered question: if the path I am in uses some symbolic link, then the new shell uses the canonical path. Is there a known fix for this problem?

Best Answer

Note: I have not tried this myself because I don’t experience this problem; of course feel free to edit this answer if changes are necessary.

This is reported as a bug in Ubuntu Gnome, but I’m not surprised it also affects Debian. The solution appears to be adding . /etc/profile.d/vte.sh to the end of your ~/.bashrc or ~/.zshrc (depending on whether you use Bash or ZSH).

Note that if you already have a PROMPT_COMMAND set in Bash, this will replace it; I believe in that case you need to set your custom PROMPT_COMMAND after the added line, and in there be sure to call __vte_prompt_command. Again, though, I have not tried this and some experimentation may be required.

Related Question