DevHawk’s Slightly Useful Powershell Configuration

Since folks were interested in my favorite tools, I thought I’d blog how I have PowerShell configured. I’m not an ultra-power user, but I hold my own and hopefully you can use some of this configuration for yourself. Please tell me you’re not still using CMD.

First, I use a trick I picked up from Tomas Restrepo to change your home directory and profile script. Here’s my Microsoft.PowerShell_profile.ps1 file (in the WindowsPowerShell subdirectory of My Documents)

# reset $HOME and $PROFILE variables
set-variable -name HOME -value "D:HPierson.Files" -force  
(get-psprovider FileSystem).Home = $HOME  
set-variable -name Profile -Value "$HomeScripts_profile.ps1"

# Run the $PROFILE script
. $profile

By default, PS uses the user’s personal directory (c:usershpierson in my case) as the home directory and the aforementioned filename for the profile script. Personally, I like to keep all “real” data off my boot partition so that I don’t have to back it all up when I repave. So my “real” home location is d:HPierson.Files. The above script sets both the $HOME variable and file system home property to this directory. It also resets the $PROFILE variable to a script in my $homeScripts folder and runs it.

My $PROFILE script does several things of note:

  • It adds the aforementioned $homeScripts folder to the path. My utilities folder is a permanent part of the path, put I only add the scripts folder when I’m actually running PS.
  • If I’m running as administrator, I set the background color of the console window to red. I think I picked up this script from Brad Wilson at some point.
  • Set location to home, otherwise when I start PS as admin, it starts in c:winsys32.
  • I have a simple prompt script file that displays current folder, the current command number and a list of yellow plus signs indicating how deep I am in the directory stack. To get it to work, I have to remove the standard prompt function, which I do in $PROFILE.
  • I can’t ever remember the space between “cd” and “..”, so I wrote a simple function called “cd..” that executes “cd ..”.
  • I have a su function that leverages the Script Elevation PowerToys. If you pass in a command, it executes it with elevated credentials. If you just execute su, it runs an elevated PowerShell.
  • I use 7-zip for my compression needs, including the 7za command line app. However, PS has issues w/ executing an exe that starts with a number. So I aliased 7za as “zip”. Update: Tomas points out that you can prepend an ampersand to force execution, so I could have typed “&7za”. I forgot that when I created the alias and am now used to using zip, so I’m not going to change it. But I thought you should know.
  • I have an ever-changing set of aliases, depending on my needs. Currently, I alias “ipy”, “cpy”, “fsi”, “fsc”, “devenv” and “chiron” to their fully path-qualified equivalents, so I can run them from anywhere without having to add their respective folders to the path.

I don’t set vsvars in the $profile script, but I do have a copy of the one Chris Tavares wrote in my scripts folder, so I can set up a VS environment in a moments’ notice.

Also, I put PowerShell on the Vista quick launch bar, so I can bring it up by typing Win-2.

Morning Coffee 171

  • Big news for IronRuby out of OSCON. John and Jim have the details. Congrats to the IronRuby folks on reaching these milestones and paving the way for others (i.e. IPy) to follow some of the same paths.
  • One of those OSCON announcements, is a project my teammate Jimmy Schementi has been working on: Silverline, which “let’s you write Rails code that can run on the client“.
  • Shri Borde – the dev manager for IPy, IRuby and F# – tackles a tricky subject of static compilation of dynamic Python code. This came up on the mailing list recently as one of the outstanding requests for IPy to do is support custom attributes, which requires static compilation. Shri lays out some of the big issues with this approach. However, the community has been fairly clear on this, so it’s obviously something we need to look at.
  • I met someone from MS Research at the MS Product Fair who pointed me to the Institute for Personal Robots in Education, a joint effort between Georgia Tech and Bryn Mawr College and sponsored by Microsoft Research. Their Myro software (myro == my robot) is written in CPython, but there’s an effort underway (aka Miro 3.0) to build a .NET version that uses IronPython. Must investigate.
  • Seshadri shows how easy it is to extend C# types in IronPython. It’s also shows how simple it is to host DLR code in your app – it’s like 6 lines of code!
  • Early reviews of IronPython in Action are good.
  • If you want to run an IronPython IDE in your browser with Silverlight, check out SilverShell from Dan Eloff.
  • The XNA team has announced their business plans for community games. Basically, you set a price point between 200 and 800 points (aka between $2.50 and $10) and receive a “baseline” of 70% of the revenue the game generates. More details are available in the FAQ. This is pretty excited. I’d like to build some co-op kids games.
  • Speaking of XNA, Caligari is now offering TrueSpace 7.6 for free . David Weller and Glenn Wilson provide an XNA viewpoint on the announcement, Chris Pendleton shows how to upload your models to VirtualEarth.
  • Congrats to the CodePlex team on their latest drop, which features that a cool new feature – Mailing Lists! IronPython has had a Mailman mailing list for years, so I’m not sure we’ll use this feature on IPy, but I’ll investigate it
  • Two PDC notes: First, Rick Rashid – VP of MS Research – will be delivering a PDC keynote. Second, the PDC team has put up a video podcast on Producing a Ginormous Conference in 10 Minutes or Less! It’s the “inaugural episode” so watch for more Countdown to PDC video podcast episodes in the future.
  • I recently discovered Chris Smith’s F# blog. He’s got recent posts on Mastering F# Lists and Guidelines for Readable F# code. For the F# novice, check out his F# in 20 Minutes posts (part one, part two)
  • Pat Helland is moving to the SQL team. Good luck Pat!
  • I like Nick Malik’s formal definition of use cases, but I can’t help be reminded of Charlie Alfred’s Value-Driven Architecture article in Architecture Journal 5 where he said use cases were “easy to teach and explain” but that “if simplicity were the only goal that counted, we’d all still be walking or riding horses to get from one place to another.”

Five Minutes Past Noon Coffee 170

  • Ben Hall announces IronEditor, a simple dev tool for IronPython and IronRuby. Pretty nice, though fairly simplistic (as Ben readily admits). For example, it doesn’t have an interactive mode, only the ability to execute scripts and direct the output to IronEditor’s output window. However, it is a good start and I’m sure it’ll just get better. One thing he’s apparently considering is a Silverlight version. (via Michael Foord)
  • Speaking of “Iron” tools, Sapphire Steel have had an IronRuby version (in alpha) of their Ruby in Steel product for several months now. I wonder if John’s had a chance to play with it.
  • Speaking of John, the ASP.NET MVC / IronRuby prototype he talked about @ TechEd is now available on ASP.NET MVC Preview 4 via Phil Haack.
  • Ted Neward has an article exploring the IronPython VS Integration sample that ships in the VS SDK. As I mentioned the other day, we’re starting working on a production quality implementation of VS Integration for IPy.
  • Ophir Kra-Oz (aka Evil Fish) blogs Python for Executives. I like his “Risk, Recruiting, Performance and Maturity” model – four boxes, perfect for keeping an executive’s attention! 😄 Plus Ophir has some nice things to say about IronPython. (via Michael Foord)
  • Ronnie Maor blogs an extension method for PythonEngine to make Eval simpler. I especially like how he uses string format syntax so you can dynamically generate the code to eval. I wonder what this would look like in IPy 2.0 with DLR Hosting API. (via IronPython URLs)
  • Speaking of DLR Hosting, Seshadri has another great DLR hosting post, this time hosting IPy inside of VS08 so you can script VS08 events (document saved, window created, etc) with Python.
  • Justin Etheredge has a bunch of IronRuby posts – Getting IronRuby Up and Running, Running Applications in IronRuby, Learning Ruby via IronRuby and C# Part 1. (via Sam Gentile)
  • Don Syme links to several F# related posts by Ray Vernagus, though he’s apparently also experimenting with IronRuby. I’m really interested in his Purely Functional Data Structures port to F#.
  • Speaking of F#, Brian has a teaser screenshot of F# upcoming CTP. However, he chooses the New Item dialog to tease, which looks pretty much like the current new item dialog (the new one does have fewer F# templates). However, if you look in the Solution Explorer, you’ll notice a real “References” node. No more #I/#R! Yeah!
  • The interactive graphic in Kevin Kelly’s One Machine article is fascinating. It really highlights that the vast vast vast majority of power, storage, CPU cycles and RAM come from personal computers on the edge. Even in bandwidth, where PC’s still have the highest share but it looks to be around 1/3rd, the aggregate of all edge devices (PCs, mobile phones, PDAs, etc.) still dominates the data centers.

Morning Coffee 169

  • Check out the crowd
    for a the Washington Capitals developmental camp scrimmage last week (My parents are in their somewhere). Standing room only in the practice facility to watch a bunch of kids, most of whom won’t ever make it to the NHL, in July. If you think Washington can’t be a hockey town, you are sorely mistaken.
  • Speaking of the Caps, they are establishing a “spirit squad“? Is that really necessary? (short answer: no). Peerless’ take is hilarious.
  • Seshadri Vijayaraghavan is a tester on the DLR team and he’s been writing quite a bit about the DLR hosting API. He’s got a series of posts about hosting, invoking and redirecting output from IronPython in a C# application.
  • I haven’t seen an official announcement, but mobile access to Live Mesh is available by pointing your phone browser to http://m.mesh.com. It’s mostly a web view of the Live Desktop, though there is a feature to upload photos from your phone. However, for some reason that feature doesn’t work for me right now. I don’t get the “browse” button.
  • ASP.NET MVC Preview 4 is available for download. Phil Haack has a few details that ScottGu didn’t cover. Scott Hanselman shows off some AJAX stuff.
  • Speaking of Scott Hanselman, he highlights the return of Terrarium from Bil Simser. Scott mentions that most Terrarium animal implementations were big collections of nested if statements. I wonder if F# pattern matching would be a cleaner approach?
  • Ted Neward obviously never “even tangentially” touched politics, as I think they have far worse flame wars far more often than we have in the software industry. However, certainly the Scala flame war he’s commenting on seems fairly counterproductive.
  • Brad Wilson runs into a wall trying to convert a string to an arbitrary Nullable<T>.He doesn’t find an answer, but I found reading thru the steps he took to try and find an answer strangely compelling.
  • Jeff Atwood argues that Maybe Normalization isn’t Normal. It’s mostly a collection of information from other places, including a compilation of high-scale database case studies. But it’s a useful collection of info and links, with a little common-sense thrown in for good measure.
  • I have a hard time imagining Pat Helland camping.

IronPython Post 2.0 Roadmap

Michael Foord (aka voidspace) twittered that “None of the IronPython team can get it together to blog regularly, except @jschementi of course.” While I’m not sure Jimmy is all that prolific either, Michael’s certainly right about me. I started this job at the beginning of April, and I’ve only blogged twenty one times in the three and a half months since. Worse, I’ve only blogged six times in the past month and a half – and half of those have been since Michael called out my lack o’ posting. My wife has blogged like twenty five times in that same time period. I can only plead pressures of a new job plus a two week vacation. I have been twittering a lot.

Michael was twittering in response to Todd Ogasawara’s post wondering about our Python 3.0 plans. Since we haven’t been particularly transparent (my fault) I thought I’d lay out our near and middle term plans.

First off, we’re on the verge of releasing 1.1.2 (the release candidate is available now), a service release in our 1.x branch which contains a bunch of bug fixes we’ve back ported from our 2.0 work. This is our last planned release in the 1.x branch. For those who don’t know, our 1.x branch tracks CPython’s 2.4 branch.

Most of our team’s focus has been on 2.0 which we’re on track to shipping later this year. Our 2.0 corresponds to CPython’s 2.5 branch. It’s a major release for us because of the addition of the Dynamic Language Runtime. Currently, you can get 2.0 Beta 3, with Beta 4 scheduled for early August (we go about 6 weeks between beta releases). If you want even fresher code than our latest release, you can pull and build the source yourself. We went about two months without pushing source due to some broken scripts, but they’re fixed now so we’re going to try and push out code much more often than we have in the past.

For the non-Python geeks in the audience, Python is undergoing a major change. Python 3.0 is going to break backwards compatibility with Python 2.x in number of ways. Breaking backwards compatibility always has to be handled carefully, so the Python community is investing quite a bit of effort to make the transition as smooth as possible.The Python Software Foundation is currently working on both 2.6 and 3.0 simultaneously. The idea is to have as much feature parity between the two releases (except for the stuff being removed from 3.0) and to provide an automatic tool to translating to the new version.

Let me be very clear (since as Todd discovered, we haven’t been to date) that once we get IronPython 2.0 out the door, we will start working towards IronPython 3.0, which will be our version of Python 3.0. We want to take the same stepping-stone approach that CPython is taking. So that means at a minimum we’ll do an IPy 2.1 with CPython 2.6′s new language and library features, (along with the usual bug fixing and other quality improvements we do every cycle) before then proceeding to work on IPy 3.0.

Until we get IPy 2.0 out the door, I’m not willing to talk about specific timelines. We’re an agile project and we’re going to be feature and quality driven, full stop. There were about seven months between the release of IPy 1.0 and 1.1, however that didn’t include much new Python feature work so it’s not a good comparison IMO. My gut tells me the IPy 2.1 release will take longer than a typical minor release while the IPy 3.0 release won’t take as long as a typical major release. Note, those are guesses, not commitments.

Besides IPy 2.1 and 3.0, the other major thing we’re working on is Visual Studio integration for IronPython. Yes, there is IronPythonStudio, but that’s a VS SDK sample not a production-quality VS integration the IPy team maintains or supports. The IntelliSense implementation is pretty flaky, the compile-oriented project system feels pretty un-pythonic and of course we need to upgrade it to support IPy 2.0 and the DLR (it would be nice if IronRuby could leverage our efforts down the road). Like everything else we do in this group, we’ll be publishing the VS Integration source code up on CodePlex as early and often as we can.

So to recap our current thinking:

  • IPy 1.1.2 in RC now, shipping in several weeks assuming we don’t find any major regressions
  • IPy 2.0 in beta now, shipping later this year
  • IPy 2.1 supporting new CPy 2.6 features at some point after IPy 2.1, probably longer than a typical minor release
  • First release of IPy integration with VS in the same timeframe as IPy 2.1 but with alpha drops as soon as we can
  • IPy 3.0 supporting new CPy 3.0 after IPy 2.1, probably shorter than a typical major release

One last thing, as many of you know the IronRuby project supports community contributions to the standard libraries. I wanted the IPy community to know I’m 100% committed for establishing a similar arrangement for IronPython. I’ve got nothing to announce yet, but rest assured I’ve been spending a lot of time talking to lawyers.

As always, if you’ve got opinions to share please feel free to leave me comments below, shoot me an email, or join the IPy mailing list.