diff --git a/base/Setup-MyPowerLineTheme.ps1 b/base/Setup-MyPowerLineTheme.ps1 index d082788..5e0d139 100644 --- a/base/Setup-MyPowerLineTheme.ps1 +++ b/base/Setup-MyPowerLineTheme.ps1 @@ -1,7 +1,8 @@ +Set-PowerLinePrompt -PowerLineFont + $local:MyPowerLineSetup = [ordered]@{ Title = { "Sz PS" } SetCurrentDirectory = $true - PowerLineFont = $true RestoreVirtualTerminal = $true PowerLineCharacters = [ordered]@{ ColorSeparator = "$([char]::ConvertFromUtf32(0x2588) @@ -19,7 +20,7 @@ $local:MyPowerLineSetup = [ordered]@{ { New-PromptText -EBg VioletRed4 $MyInvocation.HistoryId } { Get-Elapsed -Trim } { Get-SegmentedPath -LengthLimit 30 } - { $local:_git_prompt = Write-VcsStatus; if( $_git_prompt ) { "$([PoshCode.Pansies.Entities]::ExtendedCharacters.Branch)$_git_prompt" } } + { if( Get-GitStatus ) { "$([PoshCode.Pansies.Entities]::ExtendedCharacters.Branch)$(Write-VcsStatus)" } } # Right-align block { "`t" } @@ -32,4 +33,6 @@ $local:MyPowerLineSetup = [ordered]@{ { New-PromptText { "PS" } -Ebg Red } ) } -Set-PowerLineTheme @MyPowerLineSetup \ No newline at end of file +Set-PowerLinePrompt @MyPowerLineSetup + +Write-Host -ForegroundColor Cyan "PowerLine Theme is ready, if you want to persist it, don't forget to run Export-PowerLinePrompt" diff --git a/base/Start-GitHubDirDownload.ps1 b/base/Start-GitHubDirDownload.ps1 new file mode 100644 index 0000000..945a481 --- /dev/null +++ b/base/Start-GitHubDirDownload.ps1 @@ -0,0 +1,61 @@ +[CmdletBinding()]param( + [Parameter(Mandatory)] + [string]$GitHubProject, + [string]$Directory, + [string]$Destination='.', + [switch]$Update, + [string]$BackupRelativePath="" +) + +$local:testReq = $(try { + Invoke-WebRequest "https://github.com/$GitHubProject/tree/HEAD/$Directory" -UseBasicParsing -ErrorAction Stop + } catch {}) +if( 200 -ne $testReq.StatusCode ) { + Write-Verbose $($testReq|Format-List|Out-String) + Write-Error "Request failed for $GitHubProject : $Directory" + return +} + +$DestFull = Get-Item $(Join-Path $Destination '.') +Write-Verbose "DestFull: $($DestFull | Format-List | Out-String)" + +$local:tmpFile = "" +New-TemporaryFile | Select-Object -ExpandProperty FullName -OutVariable tmpFile | Remove-Item -Force +$tmpPath = New-Item -ItemType Directory $tmpFile +Remove-Variable tmpFile +Push-Location $tmpPath +Write-Verbose "tmp $($tmpPath.FullName) created" + +if( $BackupRelativePath -eq "" ) { + $BackupRelativePath = ".overitten.on.#Timestamp#" +} +$BackupRelativePath = $BackupRelativePath -replace "#Timestamp#",$(Get-Date -Format "yyyyMMdd-HHmmss") + +Write-Verbose "Fetching $Directory..." +$null = & svn checkout "https://github.com/$GitHubProject/trunk/$Directory" +$local:dirName = Split-Path -Leaf $Directory + +Remove-Item -Recurse (Join-Path $dirName '.svn') -Force + +Get-ChildItem -File -Force $dirName -Recurse | ForEach-Object { + $local:item = $_.FullName.Replace($tmpPath.FullName,'') -replace '^/','' + $local:dst = Join-Path $DestFull.FullName $item + if( Test-Path $dst ) { + if( -not $Update ) { + Write-Verbose "$dst already exists, skipping..." + return + } + if( -not (Compare-Object (Get-Content $item) (Get-Content $dst) -CaseSensitive) ) { + Write-Verbose "$dst already updated, skipping..." + return + } + $local:bkPath = Join-Path $DestFull.FullName (Split-Path -Parent $item) $BackupRelativePath (Split-Path -leaf $item) + $null = New-Item -ItemType Directory -Force (Split-Path -Parent $bkPath) -ErrorAction Stop + Move-Item -Force $dst $bkPath + } + Write-Verbose "Copy-Item -Force $_ $dst -PassThru" + Copy-Item -Force $_ $dst -PassThru +} + +Pop-Location +Remove-Item -Recurse $tmpPath -Force