steal and make some improvement from:

https://github.com/bpinto/oh-my-fish/pull/73
comment for the source