Skip to content

Commit

Permalink
add PSProfile.Modules
Browse files Browse the repository at this point in the history
for #16
  • Loading branch information
jimbrig committed Jan 17, 2024
1 parent 6975664 commit 0a44ce6
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions PSProfile/PSProfile.Modules.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,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"
}

0 comments on commit 0a44ce6

Please sign in to comment.