Using gedit to commit and push to GitHub by a simple keyboard shortcut

Gedit is a very basic but sufficient text editor for many purposes. Following the best practice to commit early and often can be cumbersome since one have to switch to the terminal in order to add file, commit changes, and push everything to the remote repository. To easy this process commiting should be as easy as saving a file.

By the help of the gedit plugin “External Tool” we can manage with a few lines of code. Since we need to specify changes together with every commit zenity gives us the chance to enter some text before commiting the code.
#!/bin/sh
git add .
inputStr=$(zenity --entry --title="Commit Message" --text="Enter a commit message" --entry-text "minor updates")
git commit -m "$inputStr"
git push origin master

If you put this snipped as an application into the External Tool plugin you can call the script by a simple keyboard command, e.g. str + g

The External Tool plugin making it easy to commit and push with gedit

Now you can call the script even from files that are nested inside your repository folders.

Leave a Reply

Your email address will not be published. Required fields are marked *