Tag Info

New answers tagged

0

I will contribute my own answer. An option, in the context of interactive shell (the question focuses on this context), could be automatically maintaining a link à la /proc/$PID/cwd, using the automation opportunity Bash provides: PROMPT_COMMAND="ln -sfT \$(pwd) ~/$LINK_NAME" The f option is required, as the link will be frequently overridden. The T ...


3

POSIX doesn't offer much in terms of getting information about unrelated processes. There's only ps, really, and it doesn't give any information about the current directory. The C-level APIs aren't any better (in fact most of the information retrieved by ps can only be retrieved by parsing its output¹). Funnily enough POSIX does offer a portable way to go ...


4

I have a solution that uses lsof. It is not installed on BSD by default so if anyone want to use it on BSD, it is required to install it. Make a shell script: #!/bin/sh lsof -p $1 | grep cwd | awk '{print $9}' Copy it to a directory in your path. It prints the working directory of PID given in the first argument, I.E. $ script 1987 /home/enedil



Top 50 recent answers are included