Replace `~` with `$HOME` in script