Add support for prepending a prefix to the start of a command

This pull request adds support for appending a prefix to the start of a command. It combines multiple regular expressions into one which is more efficient.

In case you're confused, the first commit's message has a typo in it which I did not notice till now.