Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • Hello @Rolf, thanks for answer. But as you can see, I tried something like this (unix.stackexchange.com/a/323920/381656). If I run this command from simple terminal it works fine. But if I put in .bashrc then it always changes present directory into home directory. For example if I use split screen in terminator, then instead of opening in that directory it opens in home directory. Commented Dec 15, 2020 at 16:22
  • And this is happening because .bashrc is always runs twice. And I think in process it losses arguments of current directory, passed while opening new tab. Commented Dec 15, 2020 at 16:24
  • I see. I have put the line I wrote above at the every end of my .bashrc and it worked just fine. Since the script invocation stats itself a new bash subprocess the latter will just start start in ~; that's the default. You can probably tweak within terminator. You'll need to pass the cwd as argument somehow. There will probably be other issues like this when starting script from within your .bashrc.environment then. Commented Dec 16, 2020 at 13:18
  • Problem is not terminal specific. If I use xfce4-terminal instead of terminator, and try to open new tab in any directory, it always opens in home directory. And if I remove script line from .bashrc then it opens in that directory. Commented Dec 16, 2020 at 16:38
  • Yes, I know. I said you might need to find a terminal-specific solution to that terminal-unspecific problem. It is complicated to have both a) run script that executes bash on startup and b) keep the cwd of the parent process. Commented Dec 17, 2020 at 8:25