-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_terminalmods.ps1
105 lines (85 loc) · 3.9 KB
/
install_terminalmods.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# PowerLine for Windows Terminal install posh-git and oh-my-posh
<# write-output "Installing posh-git and oh-my-posh in support of powerline customization for Windows Terminal"
install-module oh-my-posh -scope CurrentUser -force
install-module posh-git -Scope CurrentUser -force
install-module wttoolbox -Scope CurrentUser -force
#>
function add-Font() {
[CmdletBinding()]
param (
[parameter()]$FontURI,
[parameter()]$FontFile,
[parameter()]$Fontdir
)
# downloads the compressed font File, expands it, then deletes the base file
Invoke-WebRequest -Uri $FontURI -OutFile $FontFile
Expand-Archive $FontFile -DestinationPath $Fontdir
Remove-item $FontFile
#font variables
$FontItem = Get-Item -Path $Fontdir
$FontList = Get-ChildItem -Path "$FontItem\*" -Include ('*.fon','*.otf','*.ttc','*.ttf') -Recurse
#for each font
foreach ($Font in $FontList) {
Try {
$Installedfont = Get-ItemPropertyValue -Path "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Fonts" -Name $Font.Basename
}
Catch {
Copy-Item $Font "C:\Windows\Fonts"
New-ItemProperty -Name $Font.BaseName -Path "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Fonts" -PropertyType string -Value $Font.name
}
}
Remove-Item -Recurse -force $Fontdir
}
# Customize the powershell prompt
write-output "Writing customizations for Powershell command prompt..."
if (!(Test-Path -Path $PROFILE)) {
New-Item -ItemType File -Path $PROFILE -Force
}
Install-Module -Name 'posh-git' -Scope 'CurrentUser'
Install-Module -Name 'Az.Tools.Predictor' -Scope 'CurrentUser'
Install-Module -Name 'terminal-icons' -Scope 'CurrentUser'
Install-Module -Name 'PSReadLine' -AllowPrerelease -Scope 'CurrentUser' -Force
Install-Module -Name 'Az.Tools.Predictor' -Scope 'CurrentUser'
Install-Module -Name 'Az.Tools.Accounts' -Scope 'CurrentUser'
$TI="Import-Module 'Terminal-Icons'"
$PoshGit="Import-Module 'posh-git'"
$PSRL="Import-module 'PSReadLine'"
$PSTP="Import-module 'Az.Tools.Predictor'"
$SetTheme="Set-Theme 'Paradox'"
$SetReadLine="Set-PSReadLineOption -PredictionSource 'HistoryAndPlugin' -PredictionViewStyle 'ListView'"
if (!(select-string -path $PROFILE -pattern $TI)) {
add-content -Path $PROFILE -value $TI
}
if (!(select-string -path $PROFILE -pattern $PoshGit)) {
add-content -Path $PROFILE -value $PoshGit
}
if (!(select-string -path $PROFILE -pattern $PSRL)) {
add-content -Path $PROFILE -value $PSRL
}
if (!(select-string -path $PROFILE -pattern $PSTP)) {
add-content -Path $PROFILE -value $PSTP
}
if (!(select-string -path $PROFILE -pattern $SetTheme)) {
add-content -Path $PROFILE -value $SetTheme
}
if (!(select-string -path $PROFILE -pattern $SetReadLine)) {
add-content -Path $PROFILE -value $SetReadLine
}
write-output "Downloading MS Cascadia Code font..."
$FontURI = 'https://github.com/microsoft/cascadia-code/releases/download/v2102.25/CascadiaCode-2102.25.zip'
$FontFile = '.\CascadiaCode-2102.25.zip'
$Fontdir = '.\CascadiaCode-2102.25\'
add-Font $FontURI $FontFile $Fontdir
# PowerLine Cascadia font download and install for Powerline customization. This font contains the special git-related glyphs that powerline needs to fancy-up the prompt.
write-output "Downloading Caskadia font..."
$FontURI = 'https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/CascadiaCode.zip'
$FontFile =".\CaskadiaCode.zip"
$Fontdir = ".\CaskadiaCode\"
add-Font $FontURI $FontFile $Fontdir
# Installs new fonts for "All users" - requires elevated admin priv to run this
write-output "Downloading Meslo Nerd font..."
$FontURI = 'https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/Meslo.zip'
$FontFile = ".\Meslo.zip"
$Fontdir = ".\Meslo\"
add-Font $FontURI $FontFile $Fontdir
write-output "Completed Powerline Installation and Config! Open a new terminal Windows Terminal window to see the changes."