history- and completion-related tweaks, re-imported from oh-my-szsh