Save the current session in a file with the
And then restore it the next time with:
I’m going to have to use this a lot from now onwards.
Thanks to Julia’s post I learned a new thing.
The basic format is:
ls *.rb | entr bash some-script.sh
This will run the
some-script.sh script every time any of the ruby files in the current directory changes. If we are writing some simple script, then this is a very fast way to get feedback on the changes and see the program running without any extra effort!
We can use the
-r flag to re-run any server process.
git ls-files | entr rails server
Any files that git tracks in the current folder, if any of them change, then rails server will be restarted.
Docker - How to attach to the same container’s process in a new terminal session?
With this docker run command, I was in the bash prompt of the ubuntu system:
docker run --rm -it ubuntu bash
Once in, I wanted to test the
entr command. So I installed it and ran this command:
ls tmp.txt | entr bash script.sh
The script was just echoing some string. This command made the process run in the foreground. So I couldn’t test it in the same session.
In my local laptop, in another terminal session, I ran this command to login to the same docker container process:
docker exec -it 12c5eb238406 bash
12c5eb238406 is the container id I got from
docker ps. Now I was able to add lines to the tmp.txt file and see
entr running the script in the other terminal window.