While I was visiting New York a few weeks ago, I paired on writing arbitrary git commands with Jeff Fowler.
Jeff’s idea was to make a useful command that opens files edited in the last commit based on what you have set as your
Adding a command like this is super trivial:
- Name the script file to the pattern
git-COMMAND, ex. git-open
- Make sure it’s executable (
- Save the file somewhere in your
… that’s it.
The other cool thing is that since it’s any script, that means you can write it in whatever you want, including Node.js! Behold
git butts (which was, in fact, the arbitrary keyword Jeff chose when showing me this trick):
As you can see from
git open it makes more sense, process wise, to create git commands associated with doing git things.
But you don’t have to, so let’s make another thing that doesn’t care about git, but is something you might need while you’re using it:
This will print a random encouraging message when you use
git encourage. Might be useful 🙂
2 Replies to ““git butts” : Add your own commands to git! With Node!”
hey cool stuff!
just wanted to point out that you can also do this via aliasing (by editing ~/.gitconfig). you can execute arbitrary stuff in the alias with a bang like so: “butts = !echo butts”
Thanks for sharing!