First of all, if you know that you are going to squash your next commit when doing it, you can just use git commit --amend
instead. Here's example workflow:
$ git commit -am "Add a search box"
$ vim file1.c # fix something
$ git commit --amend file1.c
Git interactive mode, as the name suggest, is designed for interactive use. You can, however, do this using GIT_SEQUENCE_EDITOR
environment variable or sequence.editor
config option. Both works the same - you can set them to some script that will get a standard interactive rebase file as an input. It's output will be used for actual rebase. You can see some suggestion on how to use it in this question.