Improving command line history search and removing trailing whitespaces automatically