Get Terminal tab current directory when process is running

2

Is it possible to get tabs current directory when process is running in that tab without stopping that process? My intention is to create tab next to current with same directory. I sure can press ⌃Z, run dt (ruby script using appscript that duplicates tab) and then fg, but I hope for way without stopping process.

tig

Posted 2010-11-13T16:46:33.517

Reputation: 3 906

Answers

1

In another terminal tab/windows try ps -Exwwww this will list all your processes and their environment which will include PWD which will be the currect directory whe the process started.

You will have to manually work out which process is the one started in the tab.

See Apple's man page for ps. the -E shows the environment and -x all your processes.

user151019

Posted 2010-11-13T16:46:33.517

Reputation: 5 312

Is it possible to get that list with better separation of environment variables, as if I have space or = in path, than it will be hard to separate variables. – tig – 2010-11-15T20:41:10.790

You will have to write a script that cleans up the output from ps – user151019 – 2010-11-16T09:37:16.883

0

You can append an & to the command so it will run in the background and you will be able to work in the same tab in the current directory.

Simply run: fg &

But, the output of the command will still be displayed in Terminal, to make the command 'quiet' do: fg &> /dev/null &

Hope this helps!

Wuffers

Posted 2010-11-13T16:46:33.517

Reputation: 16 645

1 — I need only to know directory, not to work in same tab, 2 - I need all this when process is already started and I did not know that I will need tab in same dir when starting that process – tig – 2010-11-13T20:43:10.333

Well, in bash-it there is a tab function to open a new tab with the current directory, but you can't have a process running to use it.

– Wuffers – 2010-11-13T23:18:22.303