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:
> git add .
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:
> 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:
> 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:
> doskey /macros
Now, to save them, just send the output to a file like so:
> doskey /macros > macros.txt
And to load them back in a new session:
> 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