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.
if both commit 3f6289e and f580d78 are in place the 'default' will be loaded and both cases will work as expected.

Just to be clear I'm not 100% sure that proposed by me changes will not cause the regressions or bugs, because I did not provide any tests for them. 
But I'm trying to do my best to highlight the parts which I think can be improved/fixed. I'm not expecting that this pull request will be merged, but I hope that it will help with fixing hooks issues.