Skip to content

Commit 36670ea

Browse files
committed
Merge branch 'master' into development
2 parents 09ab2f2 + a0d085f commit 36670ea

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ However, Cmder can in fact run in a variety of other terminal emulators, and eve
354354

355355
*Note:* Cmder includes built-in support for Windows Terminal directory tracking via OSC 9;9 sequences. This enables "Duplicate Tab" and "Split Pane" features to preserve the current working directory for both `cmd.exe` and PowerShell sessions.
356356

357-
*Note:* Cmder also includes built-in support for Windows Terminal shell integration via OSC 133 sequences (A, B, C) for PowerShell sessions. This enables features like command navigation (jump between commands), command selection, visual command separators, and improved command history management in Windows Terminal.
357+
*Note:* Cmder also includes built-in support for [Windows Terminal shell integration](https://learn.microsoft.com/en-us/windows/terminal/tutorials/shell-integration) via OSC 133 sequences (A, B, C) for PowerShell sessions. This enables features like command navigation (jump between commands), command selection, visual command separators, and improved command history management in Windows Terminal.
358358

359359
For instructions on how to integrate Cmder with your IDE, please read our [Wiki section](https://github.com/cmderdev/cmder/wiki#cmder-integration).
360360

vendor/profile.ps1

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,25 @@ $moduleInstallerAvailable = [bool](Get-Command -Name 'Install-Module' -ErrorActi
3434
# Add Cmder modules directory to the autoload path.
3535
$CmderModulePath = Join-path $PSScriptRoot "psmodules/"
3636

37+
# Import Cmder functions
3738
$CmderFunctions = Join-Path $CmderModulePath "Cmder.ps1"
3839
. $CmderFunctions
3940

40-
if(-not $moduleInstallerAvailable -and -not $env:PSModulePath.Contains($CmderModulePath) ) {
41+
# Configure PSModulePath to include Cmder modules if not already present
42+
if (-not $moduleInstallerAvailable -and -not $env:PSModulePath.Contains($CmderModulePath) ) {
4143
$env:PSModulePath = $env:PSModulePath.Insert(0, "$CmderModulePath;")
4244
}
4345

44-
$gitVersionVendor = (readVersion -gitPath "$ENV:CMDER_ROOT\vendor\git-for-windows\cmd")
46+
# Read vendored Git Version
47+
$gitVersionVendor = (readGitVersion -gitPath "$ENV:CMDER_ROOT\vendor\git-for-windows\cmd")
4548
Write-Debug "GIT VENDOR: ${gitVersionVendor}"
4649

47-
# Get user installed Git Version[s] and Compare with vendored if found.
50+
# Get user installed Git version(s) if found, and compare them with vendored version.
4851
foreach ($git in (Get-Command -ErrorAction SilentlyContinue 'git')) {
4952
Write-Debug "GIT PATH: {$git.Path}"
5053
$gitDir = Split-Path -Path $git.Path
5154
$gitDir = isGitShim -gitPath $gitDir
52-
$gitVersionUser = (readVersion -gitPath $gitDir)
55+
$gitVersionUser = (readGitVersion -gitPath $gitDir)
5356
Write-Debug "GIT USER: ${gitVersionUser}"
5457

5558
$useGitVersion = compare_git_versions -userVersion $gitVersionUser -vendorVersion $gitVersionVendor
@@ -72,7 +75,7 @@ foreach ($git in (Get-Command -ErrorAction SilentlyContinue 'git')) {
7275
}
7376
}
7477

75-
# User vendored Git.
78+
# Use vendored Git if no user Git found or user Git is older than vendored Git
7679
if ($null -eq $ENV:GIT_INSTALL_ROOT -and $null -ne $gitVersionVendor) {
7780
$ENV:GIT_INSTALL_ROOT = "$ENV:CMDER_ROOT\vendor\git-for-windows"
7881
$ENV:GIT_INSTALL_TYPE = 'VENDOR'
@@ -85,11 +88,14 @@ if ($null -ne $ENV:GIT_INSTALL_ROOT) {
8588
$env:Path = Configure-Git -gitRoot "$ENV:GIT_INSTALL_ROOT" -gitType $ENV:GIT_INSTALL_TYPE -gitPathUser $gitPathUser
8689
}
8790

91+
# Create 'vi' alias for 'vim' if vim is available
8892
if (Get-Command -Name "vim" -ErrorAction SilentlyContinue) {
8993
New-Alias -name "vi" -value vim -errorAction SilentlyContinue
9094
}
9195

96+
# PSReadline configuration
9297
if (Get-Module PSReadline -ErrorAction "SilentlyContinue") {
98+
# Display an extra prompt line between the prompt and the command input
9399
Set-PSReadlineOption -ExtraPromptLineCount 1
94100

95101
# Add OSC 133;C support for Windows Terminal shell integration
@@ -106,17 +112,17 @@ if (Get-Module PSReadline -ErrorAction "SilentlyContinue") {
106112

107113
# Emit OSC 133;C sequence to mark start of command output
108114
# This is written directly to the console after the command is accepted
109-
[Console]::Write("$([char]27)]133;C$([char]7)")
115+
[Console]::Write("$([char]0x1B)]133;C$([char]7)")
110116
}
111117
}
112118
}
113119

114-
# Pre-assign default prompt hooks so the first run of cmder gets a working prompt.
120+
# Pre-assign default prompt hooks so the first run of Cmder gets a working prompt
115121
$env:gitLoaded = $null
116122
[ScriptBlock]$PrePrompt = {}
117123
[ScriptBlock]$PostPrompt = {}
118124
[ScriptBlock]$CmderPrompt = {
119-
# Check if we're currently running under Admin privileges.
125+
# Check if we're currently running under Admin privileges
120126
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
121127
$principal = [Security.Principal.WindowsPrincipal] $identity
122128
$adminRole = [Security.Principal.WindowsBuiltInRole]::Administrator
@@ -220,15 +226,15 @@ if ( $(Get-Command prompt).Definition -match 'PS \$\(\$executionContext.SessionS
220226
# Only active in Windows Terminal ($env:WT_SESSION) or ConEmu ($env:ConEmuPID)
221227
$loc = $executionContext.SessionState.Path.CurrentLocation
222228
if (($env:WT_SESSION -or $env:ConEmuPID) -and $loc.Provider.Name -eq "FileSystem") {
223-
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]27)]9;9;`"$($loc.ProviderPath)`"$([char]27)\"
229+
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]9;9;`"$($loc.ProviderPath)`"$([char]0x1B)\"
224230
}
225231

226232
# Emit OSC 133;A sequence for Windows Terminal shell integration
227233
# This marks the start of the prompt
228234
# Enables features like command navigation, selection, and visual separators
229235
# Only active in Windows Terminal ($env:WT_SESSION)
230236
if ($env:WT_SESSION) {
231-
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]27)]133;A$([char]7)"
237+
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]133;A$([char]7)"
232238
}
233239

234240
$host.UI.RawUI.WindowTitle = Microsoft.PowerShell.Management\Split-Path $pwd.ProviderPath -Leaf
@@ -243,7 +249,7 @@ if ( $(Get-Command prompt).Definition -match 'PS \$\(\$executionContext.SessionS
243249
# Emit OSC 133;B sequence for Windows Terminal shell integration
244250
# This marks the start of command input (after prompt, before user types)
245251
if ($env:WT_SESSION) {
246-
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]27)]133;B$([char]7)"
252+
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]133;B$([char]7)"
247253
}
248254

249255
$global:LastExitCode = $realLastExitCode

vendor/psmodules/Cmder.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function readVersion($gitPath) {
1+
function readGitVersion($gitPath) {
22
$gitExecutable = "${gitPath}\git.exe"
33

44
if (-not (Test-Path "$gitExecutable")) {
@@ -18,7 +18,7 @@ function readVersion($gitPath) {
1818
}
1919

2020
function isGitShim($gitPath) {
21-
# check if there is a shim file - if yes, read the actual executable path
21+
# Check if there is a shim file - if yes, read the actual executable path
2222
# See: github.com/ScoopInstaller/Shim
2323

2424
if (Test-Path "${gitPath}\git.shim") {

0 commit comments

Comments
 (0)