A problem with repositories is sometimes you do not remember what commands you ran to bootstrap the application, or what generators were used. A history file similar to .bash_history would be handy for a per-project basis. The h
command above provides a wrapper around this functionality. It should be portable across any system with bash.
Run a command and write out the command to the git project's .history file, this logs $@ to .history
$ h mix phx.new project_name
$ h mix deps.get
$ h mix ecto.create
$ cat .history
mix phx.new project_name
mix deps.get
mix ecto.create
Get the last command in the history file, useful for scripting
$ h
mix ecto.create
For example, to add a commit with a message of the last command with git commit -m "$(h)"
$ git add .history
$ git commit -m "$(h)"
[main 8a24723] ls -ahl
1 file changed, 2 insertions(+)
$ git log -1
commit 8a247239342fb189f53c7680f4779ad0af8942e3 (HEAD -> main)
Author: Faheetah <[email protected]>
Date: Sat May 1 12:59:23 2021 -0500
mix ecto.create
Also worth noting another good trick if this was the last command you entered in bash.
git commit -m "$(echo !!)"