I often mistype a command. So I will type this

sublimetext myfile.txt

instead of

git add myfile.txt

When I do this, I hit up to restore the last command. But after doing so, my cursor is at the end of the previously typed line. Is there a keyboard short cut to jump back to the prompt?

  • You can also just type git add, then press Esc,. - it will type myfile.txt (the last argument of previous command) automatically. – Vi. Dec 6 '13 at 0:47
  • @Vi. Thanks. It is a bit hard to read your comment. I should type "git add" then press the esc key, then press the comma key, then press period key? – bernie2436 Dec 6 '13 at 0:52
  • Escape key, then period key. Without comma. There's more Esc-Something shortcuts actually. You can also use Alt+Period. See also: stackoverflow.com/questions/211378/hidden-features-of-bash – Vi. Dec 6 '13 at 1:00

On bash command line, I use ctrl+a to go to the beginning of command and ctrl+e to go to the end of command.


After you press Up to recall the previous line, press Home to go to the beginning of the line.

  • 1
    Gilles, you just spoiled my kinda-troll attempt. – Spidey Dec 6 '13 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.