Jumping Around the Command Line
Next time you find yourself pressing the arrow key to move to the end of the command line, stop and remember, there is a quicker way! Here are a few quick shortcuts to make your cursor movement more efficient.
Note: These are written for a Mac - swap out the Cmd button for your OS-specific alternative (e.g. Cmd on Windows). These were tested in Terminal and iTerm2 using a Bash shell. Your mileage may vary for different setups.
Jump to the end of a line
Cmd + e
Jump to the beginning of a line
Cmd + a
This gif illustrates these two keyboard shortcuts in action:
Skip over a word
Alt + → or Alt + ←
If you’re using iTerm2, you may need to configure the “alt” key to work as expected. Check out my blog post about enabling the alt key in iTerm2 for how to do that.
This gif shows using the alt key to move the cursor over whole words:
Bonus tip: how to clear the contents from the viewport of the terminal window.
Cmd + l or just type
clear and press enter.