Thursday, November 22, 2012

Batch Tip: Extend path with the current directory.


To extend the path by a directory I usually take several tries as I incorrectly type the new path line, or merge copy and paste lines.  Today I discovered a simple alternative, cd to the directory and use the %PWD% special environment variables, e.g: 




cd directory\Of\Interest
set PATH=%PATH%;"%CD"


Sunday, November 18, 2012

Downloading files in powershell

I used to download files in batch files using  wget or curl. Now that I have "the powershell" I can do better, by instantiating a WebClient object.   Here's my example dependency downloader for my coffee script unit tests.





$filesToDownload = (
"http://jashkenas.github.com/coffee-script/extras/coffee-script.js",
"https://raw.github.com/jquery/qunit/master/qunit/qunit.js",
"https://raw.github.com/jquery/qunit/master/qunit/qunit.css"
)
$webClient = new-object System.Net.WebClient

$filesToDownload | % {
$uri = new-Object System.Uri $_ ;
$localPath = "$($pwd.Path)\$($uri.Segments[-1])";
Write-Host "Writing $localPath" ;
$webClient.DownloadFile($uri,$localPath);
}

Saturday, November 10, 2012

Cool Tools: ConEmu

ConEmu is a windows console replacement. You still run cmd.exe or powershell.exe, but you get a console host which doesn't suck.  I've only been using it for a few hours but here's some of the stuff I love:






  • Multi Tab Support

  • Sane Copy/Paste Support

  • Correct Handling of Win-Left and Win-Right

  • Win7 integration (see different tabs during  icon hover)

  • Everything just works (so far)