As/when/if the spirit moves you British clause
Someone does something when they feel it is the right time.
I love home-made food, but I'll eat out if the spirit moves me.
He travels abroad when the spirit moves him.
I have no idea what he will do, he usually acts as the spirit moves him.
It is unclear information about the origin of the expression, but a source says that it came from the work 'The Quaker Doctrine of the Holy Spirit' in 1959.
To be thankful or grateful for one's good luck usually while avoiding a bad situation
You should count your lucky stars as you managed to avoid that violent car accident.