I use Screen with a lot (more than 10) of local Bash sessions inside.I send some processes (like vi file) to the background and switch between sessions very often and sometimes it's very annoying to find out where the file I have to edit is being already opened.Is there a way to share such background processes to be able to access it from any Bash sesssion inside this screen?
Share background jobs between shells
bash;gnu screen;session
No, the documentation for bash job control doesn't mention any support for sharing or adopting jobs between different bash sessions.However, reptyr will allow you to take control of a job that was backgrounded in another session, which might be close enough to what you want.reptyr requires the pid of the job you want to take over, so you have to find that pid first.  You can decide for yourself whether this is more work than just finding the original screen window.It sounds like you're mostly interested in doing this with vim (yes, you said vi, but I'm assuming vim is what you're running under the hood).  vim -r will give you a list of all open vim sessions, along with files they are editing.  Read the list, find the pid that's using the file you want, and run reptyr <pid>.To be thorough, vim won't stop you from just editing a file that's already open elsewhere - using vim -r <filename> - but remember to reload the file again with :e when you return to the original session, so your new edits are applied to the latest version.  vim will remind you about this on certain events.