DEV Community

Krzysztof Kopieczek
Krzysztof Kopieczek

Posted on

Speed up git commands with Autohotkey

Disclaimer: This solution only works on Windows.

Working with git on the command line interface seems to be faster and more productive than using a mouse. But do you know all the commands by heart? Do you type without mistakes? Yeah, me neither.

Today I present a solution - Autohotkey will complete any command for you.

How it works?

Autohotkey will complete your predefined phrases with anything you want it to. Let's start simple - watch how it works with git checkout -
image

I just write gitc and press space/tab/enter and Autohotkey completes the command for me. This is because I configured it to work this way. All "scripts" are configured in *.ahk file that should be put to startup folder (its Windows + R and shell:startup or just %appdata%\Microsoft\Windows\Start Menu\Programs\Startup).

Examples

Checkout

::gitc::
Send, git checkout -
return
Enter fullscreen mode Exit fullscreen mode

image

Rebase

::gitrm::
Send, git rebase master --rebase-merges
return
Enter fullscreen mode Exit fullscreen mode

image

Fetch and log

It's more fun because there are 2 git commands with 1 Authotkey command.

::gitfl::
Send, git log HEAD..origin/main --oneline
return
Enter fullscreen mode Exit fullscreen mode

image

But why?

I prefer command line because I do in git exactly what I indented to do. No more unexpected actions hidden on the UI. Writing commands also helps with learning and mastering git. If your goal is to have clean and readable history, that's the perfect way to go.

Now working on the command line with git should be easier and more friendly.

Documentation: https://www.autohotkey.com/docs/AutoHotkey.htm

PS

  • this will also work with any kind of scripts, not only git
  • off course, you can use Autohotkey to autocomplete your email footer or any other recurrent plain text

Latest comments (0)