-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPSIntro.psm1
More file actions
79 lines (68 loc) · 3.56 KB
/
PSIntro.psm1
File metadata and controls
79 lines (68 loc) · 3.56 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
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
#Write-Host "Detected $([System.Threading.Thread]::CurrentThread.CurrentCulture) culture" -ForegroundColor Yellow
# 17 June 2025 - need to accommodate culture detection problems on non-Windows systems Issue #6
#30 Dec 2025 Detect culture from the current thread
$culture = If ([System.Threading.Thread]::CurrentThread.CurrentUICulture.name) {
[System.Threading.Thread]::CurrentThread.CurrentUICulture.name
}
else {
"en-US"
}
$baseDir = Join-Path -Path $PSScriptRoot -ChildPath $culture
#Write-Host "Imported strings from $baseDir" -ForegroundColor yellow
#Write-Host "Detected culture: $culture" -ForegroundColor Yellow
#need to account for InvariantCulture on non-Windows systems
Import-LocalizedData -BindingVariable strings -BaseDirectory $baseDir -UICulture (Get-Culture).Name -FileName PSIntro.psd1
Get-ChildItem -Path $PSScriptRoot\functions\*.ps1 |
ForEach-Object {. $_.FullName }
#Define style settings used in the tutorials using
#the values defined by the PSReadline module
# 30 Dec 2025 begin revisions to support this module on Windows PowerShell
$e = [char]27
$bel = [char]7
$reset = "$e[0m" # $PSStyle.Reset
$cmdStyle = (Get-PSReadLineOption).CommandColor
$defaultTokenStyle = (Get-PSReadLineOption).DefaultTokenColor
$stringStyle = (Get-PSReadLineOption).StringColor
$varStyle = (Get-PSReadLineOption).VariableColor
$operatorStyle = (Get-PSReadLineOption).OperatorColor
$numberStyle = (Get-PSReadLineOption).NumberColor
$paramStyle = (Get-PSReadLineOption).ParameterColor
$titleStyle = "$e[1;4;92m" #$PSStyle.Foreground.BrightGreen + $PSStyle.Bold + $PSStyle.Underline
$highLight = "$e[1;3;92m" #$PSStyle.Foreground.Green + $PSStyle.Bold + $PSStyle.Italic
$highLight2 = "$e[96m" #$PSStyle.Foreground.BrightCyan
$highLight3 = "$e[1;93m" #$PSStyle.Foreground.BrightYellow + $PSStyle.Bold
$warnStyle = "$e[3;91m" #$PSStyle.Foreground.BrightRed + $PSStyle.Italic
$promptStyle = "$e[38;5;225m"
$table = "$e[1;32m" #$PSStyle.Formatting.TableHeader
$welcomeStyle= "$e[1;3;38;5;13m"
$underLine = "$e[4m"
$italic = "$e[3m"
#capture the user's prompt text. This will be use in the tutorials
#to simulate a PowerShell session and command
#validate a prompt is captured, otherwise use a default
$prompt = ((&prompt | Out-String) -replace "`n|`r", '').Trim()
if ($prompt.Length -eq 0) {
if ($IsWindows) {
$prompt = "PS C:\> "
}
else {
$prompt = "PS /home/$([Environment]::UserName)>"
}
}
#determine the tutorial path
$tutorialPath = Join-Path -Path $PSScriptRoot -ChildPath (Join-Path -path $culture -ChildPath 'tutorials')
if (-Not (Test-Path -Path $tutorialPath)) {
#use the en-US tutorials if the localized path does not exist
$tutorialPath = Join-Path -Path $PSScriptRoot -ChildPath 'en-US\tutorials'
}
#define a hashtable of tutorials
$tutorials = @{
'PowerShell Essentials' = Join-Path -Path $tutorialPath -ChildPath 'Invoke-PSBasicsTutorial.ps1'
'Get-Command' = Join-Path -Path $tutorialPath -ChildPath 'Invoke-GetCommandTutorial.ps1'
'Get-Help' = Join-Path -Path $tutorialPath -ChildPath 'Invoke-GetHelpTutorial.ps1'
'Get-Member' = Join-Path -Path $tutorialPath -ChildPath 'Invoke-GetMemberTutorial.ps1'
'PowerShell Profiles' = Join-Path -Path $tutorialPath -ChildPath 'Invoke-PSProfileTutorial.ps1'
'PSDrives' = Join-Path -Path $tutorialPath -ChildPath 'Invoke-PSDriveTutorial.ps1'
}
#get module version for use in Verbose messaging
$modVersion = (Import-PowerShellDataFile -Path "$PSScriptRoot\PSIntro.psd1").ModuleVersion