Is there a way to get the CWD of a terminal tab?


#1

Is there a way to get the CWD of a terminal tab (even if running a process?)


#2

Probably not if you’re running the process but you haven’t run it yet then you could run pwd.


#3

Thanks, @bradydowling! Is there a way to determine whether there’s a process running?


#4

You can list all your running processes with top or ps aux. You can also use the Cloud9 process list by clicking the stats panel in the top right corner of your IDE.


#5

This is a somewhat open question, and there is no good api for it in c9. https://github.com/c9/core/blob/master/plugins/c9.ide.terminal/aceterm/hover_link.js#L344 tries to parse path from prompt, it is possible to get cwd using tmux, and it is also possible to use things like ps, ls -la /proc/<pid>/cwd but it would require special handling on windows.

@kzidane what are you trying to implement? knowing that might help to suggest a better option.


#6

Thanks for the input, @harutyun! Will take a look at the other options.

This is to connect an “Open File” file dialog, that we created, and the focused terminal tab, if any, to make it easier to, say, change directories in the terminal, and have the file dialog open at the terminal’s CWD, when it shows up.

Probably we’ll do the same for the “Save As” dialog too.