-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.ps1
63 lines (56 loc) · 1.85 KB
/
setup.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
#Module setup
$modules = ("DockerMsftProvider", "oh-my-posh", "posh-git", "SqlServer", "PSReadline", "Terminal-Icons")
foreach($module in $modules)
{
If (-not(Get-InstalledModule $module -ErrorAction silentlycontinue))
{
Write-Output "$module not installed, installing..."
Install-Module $module -AllowPrerelease}
Else
{
Write-Output "$module is installed, updating..."
Update-Module $module
}
Write-Output "$module done."
}
#Profile setup
if (!(Test-Path $PROFILE))
{
Write-Host "Profile file doesn't exist, creating..."
New-Item -type "file" -path $PROFILE
Write-Host "$PROFILE created."
}
$profileCommands = ("Import-Module posh-git" `
, "Import-Module oh-my-posh" `
, "Import-Module PSReadline" `
, "Set-PoshPrompt -Theme blueish" `
, "Import-Module -Name Terminal-Icons")
$profileContents = Get-Content $PROFILE
if($null -eq $profileContents)
{
$profileContents = ""
}
foreach($profileCommand in $profileCommands)
{
if($profileContents.Indexof("$profileCommand") -eq -1)
{
Write-Output "$profileCommand not found, adding..."
$addedContents += "`n$profileCommand"
Write-Output "$profileCommand added."
}
else
{
Write-Output "$profileCommand already exists."
}
}
if($addedContents -match "\S")
{
Write-Output "Updating profile..."
"$addedContents" |Add-Content -Path $PROFILE
Write-Output "Done."
}
#Setup PSReadline
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -EditMode Windows
Write-Output "Now install a font which includes programming ligatures. 'Caskaydia Cove Nerd Font Complete Windows Compatible.ttf' from Nerd Fonts is recommended. https://www.nerdfonts.com/font-downloads"