-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathPSProfile.Modules.ps1
More file actions
42 lines (39 loc) · 1.26 KB
/
PSProfile.Modules.ps1
File metadata and controls
42 lines (39 loc) · 1.26 KB
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
# Alternate PSModulesPath (User)
if ($isWindows) {
$LocalAppDataModulePath = Join-Path -Path $env:LOCALAPPDATA -ChildPath 'PowerShell\Modules'
if (-not(Test-Path -Path $LocalAppDataModulePath)) {
New-Item -Path $LocalAppDataModulePath -ItemType Directory -Force
}
# Add to Start of PSModulePath
$env:PSModulePath = $LocalAppDataModulePath + [IO.Path]::PathSeparator + $env:PSModulePath
}
$ProfileModulesToImport = @(
'PSReadLine'
'posh-git'
'Terminal-Icons'
'PSFzf'
'PSEverything'
'CompletionPredictor'
'Microsoft.PowerShell.ConsoleGuiTools'
'F7History'
)
ForEach ($Mod in $ProfileModulesToImport) {
try {
Write-Verbose "Importing Module: $Mod"
Import-Module $Mod -ErrorAction Stop
} catch {
Write-Warning "Failed to install module: $Mod"
try {
Install-PSResource $Mod -Scope CurrentUser -Force -ErrorAction Stop
} catch {
Write-Warning "Failed to install module: $Mod"
Continue
}
} finally {
Import-Module -Name $Mod -ErrorAction SilentlyContinue
}
}
if (Get-PSResource -Name ZLocation) {
Import-Module ZLocation
Write-Host -Foreground Green "`n[ZLocation] knows about $((Get-ZLocation).Keys.Count) locations.`n"
}