Fix hooks

This pull request is combination of #3006 and #3008 

The `after_cd` and `after_use` should be fixed so there is no reason to have separate merge requests. 

Note: It contains changes in `scripts/rvm` which are different from the changes proposed in #3006.

The summarised behaviour is:

* when rvm is loading first time the `after_cd` hooks should be triggered.
* whenever a user uses the cd command `after_cd` should be triggered
* whenever rvm changes the environment  `after_use` hooks should be triggered.
can you provide more details while the current flow is not good for you, what you describe for me in case 1/2 is proper behavior, my guess is you need `after_use` to be run even after default ruby is used during rvm start, this will be different to `after_cd` which is (as understood by me) not triggered when there is no proper project file in `$PWD` during rvm start