A few updates while reviewing the code.

Clear inp_buf when before a new root worker thread begins.
No need to search scripts in currently working directory separately.
Update history UI when typing commands.
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.