If I have a bash script which is stored in a folder, is it possible to have it running on folder opening?
First example
Suppose I have the script s
in the shared folder (for example on Dropbox) foo
and whenever a user types
cd /path/to/foo
I want to display a message, let's say Hello, visitor!
. How could I do that (if I can)?
I've already seen this question but I found no examples about what it is said in the answers.
If that's not achievable in a simple way, is it possible for the same script to run upon detecting folder content changes or do I need a second script to check that and then run the former?
Second example
Same script s
located in the same shared foo
folder. If I do something like
touch test.txt
while in the foo
folder, I'd like to have another message displayed, let's say You have created a new file!
or rename the file accordingly to a standard for that folder.
With this configuration I have to make sure that whoever enters that folder triggers the script but I'm not able to redefine any builtin function nor modify bash files.