move out of global scope

change to use angular module, wrap every in anonymous function to
prevent pollution of the global scope, use lodash for a couple
iterations and change name of history array to commandHistory.