Here are a few more custom commands I use quite a bit. They’re written for Fish, but should be easy to rewrite for bash.
New Git Branch
Checking out a new branch with the -b modifier in order to create a new branch is not intuitive and a lot to type. I decided I prefer gnew instead.
Delete git branches
Now that we’ve added branches, we want an easy way to delete them.
Now you can just type gbd first-branch other_branch FOObranch and git will attempt to delete them all. I use the lowercase -d so Git will tell me if the branch is not fully merged.
NPM Uninstall
Much faster than typing npm uninstall.
Just g for git
Since Git is something I use all day, I created what basically is an alias for git.
Now I can just type g push or whatever. I’ve done the same for other very common commands I type, eg y for yarn and so forth.
Git First Push
I like to be able to just type g push when I am in a branch, to push new code. However, for that to work I need to tell Git that I want to push to the remote branch matching the name of the branch I am in. Here is a script for doing that.
Basically, I use this command the first time I push code in a new branch, and after that I can just type g push.
Those are a few of my favorites.
My one tip for creating custom commands
As a closing thought, if you are considering writing your own custom commands, don’t do what I did initially, which was to combine way too many things into one command. 😢
Not surprisingly, the custom commands I use the most are the ones that are simple and do one, or maybe two, things.