|
| 1 | +using namespace System.Management.Automation |
| 2 | +using namespace System.Management.Automation.Language |
| 3 | +using namespace System.Diagnostics.CodeAnalysis |
| 4 | + |
| 5 | +# Version: 0.1.0 |
| 6 | + |
| 7 | +# -------------------------------------------------------------------- |
| 8 | +# Current User, All Hosts Powershell Core v7 $PROFILE |
| 9 | +# Path: $Home\Documents\PowerShell\Profile.ps1 |
| 10 | +# -------------------------------------------------------------------- |
| 11 | + |
| 12 | +<# |
| 13 | + .SYNOPSIS |
| 14 | + Current User, All Hosts PowerShell `$PROFILE`: `Profile.ps1` |
| 15 | + .DESCRIPTION |
| 16 | + This script is executed when a new PowerShell session is created for the current user, on any host. |
| 17 | + .PARAMETER Vanilla |
| 18 | + Runs a "vanilla" session, without any configurations, variables, customizations, modules or scripts pre-loaded. |
| 19 | + .PARAMETER NoImports |
| 20 | + Skips importing modules and scripts. |
| 21 | + .NOTES |
| 22 | + Author: Jimmy Briggs <[email protected]> |
| 23 | +#> |
| 24 | +#Requires -Version 7 |
| 25 | +[SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', '', Justification = 'PS7 Polyfill')] |
| 26 | +[SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Profile Script')] |
| 27 | +Param( |
| 28 | + [Parameter()] |
| 29 | + [Switch]$Vanilla, |
| 30 | + |
| 31 | + [Parameter()] |
| 32 | + [Switch]$NoImports |
| 33 | +) |
| 34 | + |
| 35 | +# -------------------------------------------------------------------- |
| 36 | +# Profile Variables |
| 37 | +# -------------------------------------------------------------------- |
| 38 | + |
| 39 | +# Profile Paths |
| 40 | +$ProfileRootPath = Split-Path -Path $PROFILE -Parent |
| 41 | +$ProfileSourcePath = Join-Path -Path $ProfileRootPath -ChildPath 'Profile' |
| 42 | + |
| 43 | +# System Information |
| 44 | +if ($PSEdition -eq 'Desktop') { |
| 45 | + $isWindows = $true |
| 46 | + $isLinux = $false |
| 47 | + $isMacOS = $false |
| 48 | +} |
| 49 | + |
| 50 | +# -------------------------------------------------------------------- |
| 51 | +# Profile Environment |
| 52 | +# -------------------------------------------------------------------- |
| 53 | + |
| 54 | +# Set editor to VSCode |
| 55 | +if (Get-Command code -Type Application -ErrorAction SilentlyContinue) { |
| 56 | + $ENV:EDITOR = 'code' |
| 57 | +} |
| 58 | + |
| 59 | +if ($Host.Name -eq 'ConsoleHost') { |
| 60 | + Write-Verbose "Detected Host: 'ConsoleHost'. Loading 'PSReadLine' Setup..." |
| 61 | + . "$ProfileSourcePath/Profile.PSReadLine.ps1" |
| 62 | +} |
| 63 | + |
| 64 | +. "$ProfileSourcePath/Profile.Shorthands.ps1" |
| 65 | +. "$ProfileSourcePath/Profile.Helpers.ps1" |
| 66 | +. "$ProfileSourcePath/Profile.Integrations.ps1" |
| 67 | +. "$ProfileSourcePath/Profile.Modules.ps1" |
0 commit comments