I came across this Powershell blog post about adding folders and files to a zip archive, but it wasn't exactly 100% usable out of the box. Here's a slight re-work of the script that will have you zipping files from a prompt all day and all night:
########################################################
#
# out-zip.ps1
#
# Usage:
#
# To zip up some files:
# ls c:\source\*.txt | out-zip c:\target\archive.zip $_
#
# To zip up a folder:
# gi c:\source | out-zip c:\target\archive.zip $_
########################################################
$path = $args[0]
$files = $input
if (-not $path.EndsWith('.zip')) {$path += '.zip'}
if (-not (test-path $path)) {
set-content $path ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
}
$ZipFile = (new-object -com shell.application).NameSpace($path)
$files | foreach {$zipfile.CopyHere($_.fullname)}
Pair programming is an important part of modern-day, agile software development processes. It helps developers write better software. Pair programming is a good thing.
However, I usually can't stand watching someone else write code, or watch someone else do anything on a keyboard for that matter. It's like getting teeth pulled. No, it's like getting teeth pulled while walking on hot coals and self-inflicting paper cuts.
A few of us at work are reading The Pragmatic Programmer, which stresses knowing how to squeeze every drop of coding power out of a text editor. A developer's text editor (or IDE) is to code as a woodworker's saw is to wood. I couldn't agree more. The better you know how to work the keyboard the faster (and easier) you will be able to write code. And I'm not even talking about editors like VI and Emacs - I'm even just talking about basic Notepad operations (although I hope you're not using Notepad to write your apps).
So, here are some basics (at least on a Windows OS) that will leave your mouse-wielding co-workers in the dust, and will make me pleased to pair-program with you:
- Ctrl+X, Ctrl+C, Ctrl+V Cut, Copy and Paste
95% of developer already know these, but they save you the hassle of choosing the cut, copy, and paste commands from a toolbar or menu.
- Ctrl+[right/left arrow] Move word to word
This will move your cursor to the next "non-alphanumeric" character in a file. Meaning, if you have spaces between words it will stop at each space. Handy for moving quickly down a line of text rather than just the arrow keys alone.
- Shift+[arrow keys] Select text
Allows you to select (e.g. highlight) text without using the mouse. Use the left and right arrows to select adjacent text, or the up and down arrows to select entire lines of text.
- Ctrl+Shift+[right/left arrow] Select text word to word
This is like the Ctrl+[right/left arrow] and Shift+[arrow keys] commands combined together. You can select words while moving your cursor rather than single characters at a time.
- Home and End keys Go to the beginning or the end of a line
These are arguably two of the least-utilized keys by developers.
- Ctrl+Home and Ctrl+End Go to the beginning or the end of a document
It's like the Home and End key behavior on steroids.
- Ctrl+s Saves the file
I'm surprised at how many people still use the mouse to move their pointer to the Save button a toolbar. This shortcut will prolong carpal tunnel syndrome by 0.01% each time you use it. All major Windows text editors support this.
- Alt, with arrows Navigates menu bars
You should know keyboard bindings for commands specific to your favorite text editor. For example: closing the text editor, code indenting/formatting, etc. But if you don't, you can use alt key to enable keyboard command of the menu bar and then use the arrow keys to navigate it.
Once you've gotten the hang of these, using them in combination with each other gives you more power. For example, if you want to delete the line that your cursor is on, use the End key, then Shift+[down arrow] to select the line, then delete.
As I already mentioned, you'll need to go beyond the basic text editing commands to harness all the power of your text editor. Get to know the keyboard bindings that your editor supports to complete certain tasks and operations. You should also be able to set up custom bindings to perform commands. For example, if you really want to use the Ctrl+U, Shift+X sequence to auto-indent and format your code, then you should be able to set up that binding in your editor. If you can't do that with your text editor or IDE, then you might want to try a different one. Being able to set up a Rebuild All command in Visual Studio .Net from the keyboard is one of my first tasks after a fresh install.
Take all this only as a suggestion. I don't think you have to use keyboard shortcuts to be a good developer, and there's probably somebody out there who is faster than me by using a mouse. However I've never met such a person, and their right wrist is probably throbbing right about now. You need to do what is comfortable to you so that you like your development environment and can get your job done. But if I'm pair programming with you and you see me falling asleep as you use the mouse to select some text, now you'll know why.