I'm an efficiency freak, and if a shortcut can shave 10 seconds off a task I do a dozen times a day, well that's an extra cup of coffee I can enjoy. :D Don't worry, I'm lazy, so this blog post will be as quick as it can be.
I work on Windows systems, and I was growing tired of some of the repetitive tasks I do via the command line. If you work on Mac/Unix systems then you can use alias' for this. Since I'm lazy, I did a little bit of research on my Friday "off day". I bumped into Clink, ConsoleZ and doskey. My developer cycle has never been the same, and that's a great thing!
@echo off doskey ff="C:\Program Files (x86)\Mozilla Firefox\firefox.exe" $1 doskey gc="C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" $1 doskey sublime="C:\Program Files\Sublime Text 2\sublime_text.exe" $1 doskey explorer.chdir=explorer . doskey dk.list=doskey /macros doskey dk.edit="C:\Program Files\Sublime Text 2\sublime_text.exe" "C:\Users\Chuck\dk.cmd"
Open ConsoleZ and hit ctrl+s (which opens the Settings panel), and move to the Tabs section. Below is an example of mine, but there are a few important parts to point out.
Chuck, so that'll be the part you want to change. The full code line is
C:\Windows\System32\cmd.exe /K C:\Users\Chuck\dk.cmd; the
/Kwill open up your
dk.cmdeach time you open a new console.
dk.cmdyou have to restart your console. The change will not be automatically picked up. Don't get burned like I did. :)
@echo onwhen you open your console each time it'll echo out all of the doskeys that you are loading.
Doskey is actually a pretty simple syntax. A quick example is below.
A thing to note, do not put a space before or after the
= (equal sign). Also, do not use
&& to run multiple commands together; use
^& instead to achieve the same effect. A quick example might be that I want to switch to my blog's directory and see if I have files to commit.
doskey blog.status=cd "myBlogPath" &^ git status
Echo, Echo is nice if you need to make sure all of your commands are being executed and that there are no errors. I keep it there for debugging.
doskey test=echo "working"
This is where you can start to get into sending a file path into a program. Most programs are designed that the first param is setup to open the file. In this case the I'm essentially taking the file path and "piping" it to the program; the
$1 is the file path of what I'm trying to send to the program. It's essentially the second parameter after the name of the doskey. For example
sublime index.html would send the
index.html in my current directory to Sublime and open it up. The two doskeys below are designed to open whatever file you send to it in Firefox and Chrome.
doskey ff="C:\Program Files (x86)\Mozilla Firefox\firefox.exe" $1 doskey gc="C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" $1 doskey sublime="C:\Program Files\Sublime Text 2\sublime_text.exe" $1
Okay, this is one of my favorite shortcuts that I put in recently. It opens a file explorer in your current directory. This is super handy when you need to do a lot of file moving and or other things that require a mouse.
I use the dot-notation because it's a familiar concept form programming. A lot of my custom doskey's start with the projectname and then the action. For instance,
doskey explorer.chdir=explorer .
And this is where you take doskey to the next level.
dk.list give you a list of all of you commands in case you forgot. However, the more important command is
dk.edit. In this case I have it open in Sublime Text and it lets me edit my
dk.cmd file. This makes it super easy to add shortcuts to your dk file without having to path to it each time. Just remember to open a new command line each time because your command window will not refresh itself.
doskey dk.list=doskey /macros doskey dk.edit="C:\Program Files\Sublime Text 2\sublime_text.exe" C:\Users\crolex\dk.cmd
tl;dr I got lazy one day and found doskey. If you use the windows command line a lot you should look into these shortcuts