Configuration Scripts For Lazy Developers
Laziness is a virtue
I recently paved my laptop and set it up again from scratch. (I wanted to get rid of accumulated corporate network goo.) I always dread doing that because it takes so long to get everything installed and configured the way I like to have it, especially since I use non-default settings for several things. It’s even more obnoxious because I regularly use multiple computers and I want to have all settings the same across all of them.
Well, in the spirit of “laziness is a virtue”, I decided to start scripting some of this stuff so that I don’t have to do it by hand every time and it’ll be easier to apply a consistent set of settings across all of my machines. A full-blown automated configuration system would install software and do absolutely everything for me but I’m starting simple with some Powershell scripts that configure the behavior of Windows Explorer, the console, Git, and Notepad++.
(I have a feeling that there are already tools/projects/script libraries out there that do this sort of thing in a much more complete way but I didn’t run across anything during a quick web search. If there’s something I overlooked, let me know in the comments.)
I thought I’d share my configuration scripts/files, not because the configuration settings I choose to use are all that interesting (they’re not), but because the mechanism of where to find these settings and how to script them may be interesting for others who want to do something similar. You can find them at http://github.com/SaintGimp/ConfigurationScripts.
How I use them
So here’s the way I’m using these scripts:
- I keep them in a Configuration folder inside my WindowsPowershell folder which contains my Powershell profile, Powershell Community Extensions, and other useful Powershell stuff. I sync the WindowsPowershell folder across all of my computers using Windows Live Mesh so that when I make a change to any of the files on one computer the change shows up on all my other computers automagically.
- When setting up a new computer I’ll first install Notepad++, Git, and Windows Live Mesh, then sync the aforementioned WindowsPowershell folder.
- I start an elevated Powershell console and cd to the WindowsPowershell\Configuration folder.
- I run all of the Configure-[foo] scripts in the folder.
- When I change something about my preferred configuration, I’ll update the script files and run them on all my other computers the next time I use them.
What they do
- Configure-Console.ps1: I like to use the Consolas font and to use several other non-default settings for my console windows and I want my cmd consoles to look different than my Powershell consoles. To accomplish this I found that I need to copy modified Powershell shortcuts (which contain console settings) into the Start Menu folder, plus load other stuff into the registry for default settings and for Powershell instances that aren’t launched through the shortcuts. The registry settings are contained in a .reg file I exported from regedit after I got everything set up the way I want it.
- Configure-Explorer.ps1: I use a command from Powershell Community Extensions to add an “Open Powershell Here” context command to Windows Explorer, then I import a bunch of registry settings for view options and start menu options. Finally I add Notepad to the Send To menu and remove several other things that I never use from that menu.
- Configure-Git.ps1: This sets several Git configuration options including a prettified version of log (git lg) and Notepad++ as my default editor.
- Configure-Notepad++.ps1: I have a small shim that I register as a debugger for Notepad.exe which runs Notepad++.exe instead. I prefer doing that rather than hunting down every place that Notepad.exe may be invoked in my tools and changing the command. Next I change a couple of Notepad++ settings to the behavior I prefer.
There’s obviously a lot more that could be added but I’m going to do that on a “pain threshold exceeded” basis; that is, when configuring something by hand annoys me too much then I’ll sit down and figure out how to automate it.