Replace ~ with $HOME