Open yannickwurm opened 9 years ago
It's going to be a highly contrived solution, if at all possible.
Your shell starts switch (which is a Ruby process). Switch exec
s docker run
. exec
overwrites the current process with new process, keeping the same pid.
shell -> (ruby) -> docker
docker runs your shell or the given command as a separate process within container. switch biolinux
will look like:
sudo [pid 1] -> bash [some pid]
Either on host, or in container I can get the cwd of current process by readlink /proc/<pid>/cwd
(on Linux; using lsof
on Mac). But there's no real way for the owner process (your shell) on host to get cwd
of the shell running within the container. Either way, I don't see how to use that to set parent shell's cwd
.
I would rather you see switch as similar to "opening a new tab". Changes done in new tab don't cause any changes in other tabs. If no, it should be possible to have container print cwd
to console on quit. Then you can copy paste the path and cd
yourself, or run switch as cd $(switch bioilinux)
.
currently you end up back where switch was launched