Skip to content

Instantly share code, notes, and snippets.

@paulblamire
Last active August 29, 2015 14:07
Show Gist options
  • Save paulblamire/383b0b4e8ae4976ac170 to your computer and use it in GitHub Desktop.
Save paulblamire/383b0b4e8ae4976ac170 to your computer and use it in GitHub Desktop.
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
function downloadFile($dir, $fileName, $url)
{
$dirExists = Test-Path $dir
$fullFile = ($dir+"\"+$fileName)
if (-Not $dirExists)
{
New-Item -ItemType Directory -Force -Path $dir
}
$fileExists = Test-Path $fullFile
if (-Not $fileExists)
{
((new-object net.webclient).DownloadFile($url, $fullFile))
}
}
function extractFile($zipArchive, $fileName, $dest)
{
$zipFiles = [IO.Compression.ZipFile]::OpenRead($zipArchive).Entries
$file = $zipFiles | Where-Object {$_.Name -eq $fileName}
$fileExists = Test-Path ($dest + "\" + $fileName)
if ($fileExists)
{
Remove-Item ($dest + "\" + $fileName)
}
[IO.Compression.ZipFileExtensions]::ExtractToFile($file, $dest + "\" + $fileName)
}
function Out-ClipBoard() {
#############################################################################
##
## Out-Clipboard
##
## Originally "Set-Clipboard" From Windows PowerShell Cookbook (O'Reilly)
## by Lee Holmes (http://www.leeholmes.com/guide)
##
## copied from http://poshcode.org/2219
##
##############################################################################
<#
.SYNOPSIS
Sends the given input to the Windows clipboard.
.EXAMPLE
dir | Out-Clipboard
This example sends the view of a directory listing to the clipboard
.EXAMPLE
Out-Clipboard "Hello World"
This example sets the clipboard to the string, "Hello World".
#>
param(
## The input to send to the clipboard
[Parameter(ValueFromPipeline = $true)]
[object[]] $InputObject
)
begin
{
Set-StrictMode -Version Latest
$objectsToProcess = @()
}
process
{
## Collect everything sent to the script either through
## pipeline input, or direct input.
$objectsToProcess += $inputObject
}
end
{
## Launch a new instance of PowerShell in STA mode.
## This lets us interact with the Windows clipboard.
$objectsToProcess | PowerShell -NoProfile -STA -Command {
Add-Type -Assembly PresentationCore
## Convert the input objects to a string representation
$clipText = ($input | Out-String -Stream) -join "`r`n"
## And finally set the clipboard text
[Windows.Clipboard]::SetText($clipText)
}
}
}
Set-Alias clip Out-ClipBoard
Set-Alias Set-Clipboard Out-Clipboard
$downloadPath = 'D:\Program Files\GitFlowDependencies'
$goZip = "go.zip"
$l1Zip = "l1.zip"
$l2Zip = "l2.zip"
downloadFile -dir $downloadPath -fileName $goZip -url 'http://downloads.sourceforge.net/project/gnuwin32/util-linux/2.14.1/util-linux-ng-2.14.1-bin.zip?r=http%3A%2F%2Fgnuwin32.sourceforge.net%2Fpackages%2Futil-linux-ng.htm&ts=1412197024&use_mirror=freefr'
downloadFile -dir $downloadPath -fileName $l1Zip -url 'http://downloads.sourceforge.net/project/gnuwin32/libintl/0.14.4/libintl-0.14.4-bin.zip?r=http%3A%2F%2Fgnuwin32.sourceforge.net%2Fpackages%2Flibintl.htm&ts=1412198934&use_mirror=kent'
downloadFile -dir $downloadPath -fileName $l2Zip -url 'http://downloads.sourceforge.net/project/gnuwin32/libiconv/1.9.2-1/libiconv-1.9.2-1-bin.zip?r=http%3A%2F%2Fgnuwin32.sourceforge.net%2Fpackages%2Flibiconv.htm&ts=1412198894&use_mirror=sunet'
$x = "LOCALAPPDATA"
$localPath = (get-item env:$x).Value
$github = $localPath + "\Github"
$portableGits = Get-ChildItem -Path $github -Filter PortableGit* -Recurse
$sortedPortableGits = $portableGits | Sort CreationTime -Descending
$latestPortableGit = $sortedPortableGits | Select -First 1
$bin = $latestPortableGit.FullName + "\bin"
extractFile -dest $bin -zipArchive ($downloadPath + "\" + $goZip) -fileName 'getopt.exe'
extractFile -dest $bin -zipArchive ($downloadPath + "\" + $l1Zip) -fileName 'libintl3.dll'
extractFile -dest $bin -zipArchive ($downloadPath + "\" + $l2Zip) -fileName 'libiconv2.dll'
''
'**** Copy the following into ghfw bash ****'
'git clone --recursive git://github.com/nvie/gitflow.git'
'**** Naviate to gitflow/contrib in command.exe ****'
$installGitflow = 'msysgit-install.cmd "' + $latestPortableGit.FullName + '"'
$installGitflow
clip $installGitflow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment