A few bug fixes.

Tilda in BIN_PATH should now been recognized correctly.
Line starts with ~ no longer reports error when pressing Tab.
Add an environment variable to specify the branch to selfupdate.