Using iTerm2 for development is awesome. You can use CTRL + a to move to the start of the current line and CTRL + e to move to the end.
With long commands, it would be convenient to just jump back a few words, edit the command and then execute it. Whilst this is possible by default in iTerms2, the keys are cumbersome.
By changing the keys preset, you can get a more useful set of keyboard shortcuts.
Go to Preferences > Profiles > Keys and change the preset to ‘Natural Text Editing’.
Now you can jump back and forward on a line, one word at a time, using OPTION + left arrow and OPTION + right arrow