Committing to Doskey

I recently wrote a little about using doskey but recently had a situation in which I thought it could be really handy. I often run the following set of commands with my many, small commits:

1
2
3
> git add .
> git commit -m "A useful commit message"
> git push

That’s quite a mouthful (fingerfull) but on Windows, aliases aren’t as plentiful as in Bash and writing a small batch file or PowerShell script for this seems overkill. Instead, simply do the following:

1
> doskey gc=git add.$tgit commit -m "$*"$tgit push

Let’s quicky break that down. “$t“ tells doskey to start a new command. “$*“ is doskey’s way of saying: take everything I add on the command line after the alias, and stick it here. The quotes are important though - that makes sure your commit message remains as one parameter. Also, in case you’re wondering, $1 is the first parameter, and so on.

So, to use it, you simply need to do the following:

1
> gc My shiny new commit message

Easy, right? If you want to save your little alias, you can echo out the ones it knows about with:

1
> doskey /macros

Now, to save them, just send the output to a file like so:

1
> doskey /macros > macros.txt

And to load them back in a new session:

1
> doskey /macrofile=macros.txt

You can find out more here should you want to.


Hi! Did you find this useful or interesting? I have an email list coming soon, but in the meantime, if you ready anything you fancy chatting about, I would love to hear from you. You can contact me here or at stephen ‘at’ logicalmoon.com