Created
June 16, 2022 23:15
-
-
Save Tsugami/557bda63d26c07d2317656f3bee5988c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Write-Log { | |
param( | |
[Parameter()] | |
[ValidateNotNullOrEmpty()] | |
[string]$Message, | |
[Parameter()] | |
[ValidateNotNullOrEmpty()] | |
[ValidateSet("Info", 'Warn', 'Error', 'Success')] | |
[string]$Type = 'Info' | |
) | |
$Prompt = ""; | |
$Color = ""; | |
switch ($Type) { | |
'Warn' { | |
$Prompt = '???' | |
$Color = 'Yellow' | |
} | |
'Error' { | |
$Prompt = '---' | |
$Color = 'Red' | |
} | |
'Success' { | |
$Prompt = '!!!' | |
$Color = 'Green' | |
} | |
default { | |
$Prompt = '...' | |
$Color = 'Cyan' | |
} | |
} | |
Write-Host "[ $Prompt ] $Message" -ForegroundColor $Color | |
} | |
$UserName = "tsugami" | |
$RepoName = "dotfiles" | |
$Branch = "master" | |
$ZipUrl = "https://api.github.com/repos/$UserName/$RepoName/zipball/$Branch" | |
$ZipFile = "$HOME\.dotfiles.zip" | |
$DestPath = "$HOME\.atapo" | |
New-Item $ZipFile -ItemType File -Force | |
Write-Log "Downloading .dotfile from GitHub in $ZipFile" | |
Invoke-RestMethod -Uri $ZipUrl -OutFile $ZipFile | |
Write-Log "Download complete!" -Type Success | |
Write-Log 'Starting unzipping the .dotfiles.zp locally' | |
Expand-Archive -Path $ZipFile -DestinationPath $DestPath -Force | |
Write-Log "Unzip finished in $DestPath" -Type Success | |
Remove-Item -Path $ZipFile -Force | |
Write-Log ".dotfiles.zip deleted" -Type Success |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment