Skip to content

Commit 2ce0146

Browse files
authored
adjust comments
1 parent 5dfa14c commit 2ce0146

File tree

2 files changed

+25
-21
lines changed

2 files changed

+25
-21
lines changed

vendor/git-prompt.sh

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,21 @@ then
4747
. ~/.config/git/git-prompt.sh
4848
fi
4949
else
50-
# Source: github.com/git-for-windows/build-extra/blob/main/git-extra/git-prompt.sh
51-
50+
5251
# Setup OSC 133 shell integration for Windows Terminal
5352
if [ -n "$WT_SESSION" ]; then
5453
__cmder_prompt_command() {
5554
local exit_code=$?
56-
# OSC 133;D - Mark end of command execution with exit code
55+
# Emit OSC 133;D to mark the end of command execution with exit code
5756
printf '\e]133;D;%s\a' "$exit_code"
58-
# OSC 133;A - Mark start of prompt
59-
printf '\e]133;A\a'
6057
return $exit_code
6158
}
62-
63-
# OSC 133;C - Mark start of command output (emitted right before command execution)
59+
6460
__cmder_preexec() {
65-
printf '\e]133;C\a'
61+
printf '\e]133;C\a' # Emit OSC 133;C to mark the start of command execution
6662
}
67-
68-
# Append to PROMPT_COMMAND to emit sequences before each prompt
63+
64+
# Append to PROMPT_COMMAND to emit sequences just before each prompt
6965
if [ -z "$PROMPT_COMMAND" ]; then
7066
PROMPT_COMMAND="__cmder_prompt_command"
7167
else
@@ -75,9 +71,16 @@ else
7571
# Use DEBUG trap to emit OSC 133;C before command execution
7672
trap '__cmder_preexec' DEBUG
7773
fi
78-
74+
75+
# Source: github.com/git-for-windows/build-extra/blob/main/git-extra/git-prompt.sh
7976
PS1='\[\033]0;${TITLEPREFIX:+$TITLEPREFIX:}${PWD//[^[:ascii:]]/?}\007\]' # set window title to TITLEPREFIX (if set) and current working directory
8077
# PS1="$PS1"'\n' # new line (disabled)
78+
79+
if [ -n "$WT_SESSION" ]; then
80+
# Emit OSC 133;A to mark the start of prompt
81+
PS1="$PS1"'\e]133;A\a'
82+
fi
83+
8184
PS1="$PS1"'\[\033[32m\]' # change to green and bold
8285
PS1="$PS1"'\u@\h ' # user@host<space>
8386
PS1="$PS1${MSYSTEM:+\[\033[35m\]$MSYSTEM }" # show MSYSTEM in purple (if set)
@@ -108,9 +111,9 @@ else
108111
PS1="$PS1"'\[\033[30;1m\]' # change color to grey in bold
109112
PS1="$PS1"'λ ' # prompt: Cmder uses λ
110113
PS1="$PS1"'\[\033[0m\]' # reset color
111-
112-
# OSC 133;B - Mark start of command input (Windows Terminal only)
114+
113115
if [ -n "$WT_SESSION" ]; then
116+
# Emit OSC 133;B to mark the end of prompt
114117
PS1="$PS1"'\[\e]133;B\a\]'
115118
fi
116119
fi

vendor/profile.ps1

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ if (Get-Module PSReadline -ErrorAction "SilentlyContinue") {
9898
# Display an extra prompt line between the prompt and the command input
9999
Set-PSReadlineOption -ExtraPromptLineCount 1
100100

101-
# Add OSC 133;C support for Windows Terminal shell integration
102-
# This marks the start of command output (emitted when Enter is pressed)
101+
# Invoked when Enter is pressed to submit a command
103102
if ($env:WT_SESSION) {
104103
Set-PSReadLineKeyHandler -Key Enter -ScriptBlock {
105104
# Get the current command line
@@ -110,7 +109,7 @@ if (Get-Module PSReadline -ErrorAction "SilentlyContinue") {
110109
# Accept the line first
111110
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
112111

113-
# Emit OSC 133;C sequence to mark start of command output
112+
# Emit OSC 133;C to mark start of command output
114113
# This is written directly to the console after the command is accepted
115114
[Console]::Write("$([char]0x1B)]133;C$([char]7)")
116115
}
@@ -221,20 +220,22 @@ if ( $(Get-Command prompt).Definition -match 'PS \$\(\$executionContext.SessionS
221220
$lastSUCCESS = $?
222221
$realLastExitCode = $LastExitCode
223222

224-
# Emit terminal-specific escape sequences for Windows Terminal and ConEmu
223+
# Terminal-specific escape sequences for Windows Terminal and ConEmu
225224
if ($env:WT_SESSION -or $env:ConEmuPID) {
226-
# OSC 133;D - Mark end of command execution with exit code (Windows Terminal only)
225+
# Emit OSC 133;D to mark the end of command execution with exit code
227226
if ($env:WT_SESSION) {
228227
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]133;D;$realLastExitCode$([char]7)"
229228
}
230229

231-
# OSC 9;9 - Enable directory tracking for "Duplicate Tab" and "Split Pane"
230+
# Emit OSC 9;9 to mark the start of the prompt
231+
# Enables directory tracking for "Duplicate Tab" and "Split Pane"
232232
$loc = $executionContext.SessionState.Path.CurrentLocation
233233
if ($loc.Provider.Name -eq "FileSystem") {
234234
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]9;9;`"$($loc.ProviderPath)`"$([char]0x1B)\"
235235
}
236236

237-
# OSC 133;A - Mark start of prompt (Windows Terminal only)
237+
# Emit OSC 133;A to mark the start of the prompt
238+
# Enables features like command navigation, selection, and visual separators
238239
if ($env:WT_SESSION) {
239240
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]133;A$([char]7)"
240241
}
@@ -249,7 +250,7 @@ if ( $(Get-Command prompt).Definition -match 'PS \$\(\$executionContext.SessionS
249250
CmderPrompt
250251
PostPrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline
251252

252-
# OSC 133;B - Mark start of command input (Windows Terminal only)
253+
# Emit OSC 133;B to mark the start of command input (after prompt, before user types)
253254
if ($env:WT_SESSION) {
254255
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]133;B$([char]7)"
255256
}

0 commit comments

Comments
 (0)