Skip to content

Instantly share code, notes, and snippets.

@chromedays
Created February 21, 2019 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chromedays/4a00b5b80d7dc92d5ecf90cad771a1b1 to your computer and use it in GitHub Desktop.
Save chromedays/4a00b5b80d7dc92d5ecf90cad771a1b1 to your computer and use it in GitHub Desktop.
#Requires -RunAsAdministrator
function wait_input_before_exit()
{
if ($Host.Name -eq "ConsoleHost")
{
Write-Host "Press any key to continue...."
$Host.UI.RawUI.FlushInputBuffer() # Make sure buffered input doesn't "press a key" and skip the ReadKey().
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp") > $null
}
}
function install_scoop_packages($installed_buckets)
{
Write-Host "Installing scoop packages... via scoop_packages.txt"
$package_lines = Get-Content .\scoop_packages.txt
Foreach ($this_line in $package_lines)
{
$tokens = $this_line.Split(' ')
$package_name = $tokens[0]
if ($package_name -eq "git")
{
continue
}
$bucket_name = $tokens[2]
if ($bucket_name -ne $null)
{
$bucket_name = $bucket_name.trim('[]')
}
Write-Host $package_name $bucket_name
if ($bucket_name -eq $null -or $installed_buckets -contains $bucket_name)
{
scoop install $package_name
}
else
{
Write-Host "Failed to install $package_name due to $bucket_name not installed!"
}
}
Write-Host "Installed all scoop packages!"
}
function install_scoop($web_client)
{
Write-Host "Installing scoop..."
Set-ExecutionPolicy RemoteSigned -Scope Process
$scoop_install_script = $web_client.DownloadString('https://get.scoop.sh')
Invoke-Expression $scoop_install_script > $null
Write-Host "Installed!"
Write-Host "Adding scoop buckets..."
scoop install git > $null
$installed_buckets = "extras","versions"
Foreach ($this_bucket in $installed_buckets)
{
scoop bucket add $this_bucket > $null
}
Write-Host "Added!"
install_scoop_packages($installed_buckets)
}
function install_choco($web_client)
{
Write-Host "Installing chocolatey..."
Set-ExecutionPolicy Bypass -Scope Process
$choco_install_script = $web_client.DownloadString('https://chocolatey.org/install.ps1')
Invoke-Expression $choco_install_script > $null
Write-Host "Installed!"
Write-Host "Installing chocolatey packages via packages.config..."
choco install choco_packages.config -y
Write-Host "Installed!"
}
function setup_git_config()
{
git config --global user.email "haik0925@gmail.com"
git config --global user.name "Illkwon Ha"
git config --global core.editor "$((Get-Command vim.exe).Path -replace "\\", "/")"
}
function main()
{
$web_client = New-object System.Net.WebClient
install_scoop $web_client
install_choco $web_client
setup_git_config
}
# main
# wait_input_before_exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment