mirror of
https://github.com/cmderdev/cmder.git
synced 2025-11-09 13:49:05 +08:00
adjust comments
This commit is contained in:
19
vendor/git-prompt.sh
vendored
19
vendor/git-prompt.sh
vendored
@@ -47,25 +47,21 @@ then
|
|||||||
. ~/.config/git/git-prompt.sh
|
. ~/.config/git/git-prompt.sh
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Source: github.com/git-for-windows/build-extra/blob/main/git-extra/git-prompt.sh
|
|
||||||
|
|
||||||
# Setup OSC 133 shell integration for Windows Terminal
|
# Setup OSC 133 shell integration for Windows Terminal
|
||||||
if [ -n "$WT_SESSION" ]; then
|
if [ -n "$WT_SESSION" ]; then
|
||||||
__cmder_prompt_command() {
|
__cmder_prompt_command() {
|
||||||
local exit_code=$?
|
local exit_code=$?
|
||||||
# OSC 133;D - Mark end of command execution with exit code
|
# Emit OSC 133;D to mark the end of command execution with exit code
|
||||||
printf '\e]133;D;%s\a' "$exit_code"
|
printf '\e]133;D;%s\a' "$exit_code"
|
||||||
# OSC 133;A - Mark start of prompt
|
|
||||||
printf '\e]133;A\a'
|
|
||||||
return $exit_code
|
return $exit_code
|
||||||
}
|
}
|
||||||
|
|
||||||
# OSC 133;C - Mark start of command output (emitted right before command execution)
|
|
||||||
__cmder_preexec() {
|
__cmder_preexec() {
|
||||||
printf '\e]133;C\a'
|
printf '\e]133;C\a' # Emit OSC 133;C to mark the start of command execution
|
||||||
}
|
}
|
||||||
|
|
||||||
# Append to PROMPT_COMMAND to emit sequences before each prompt
|
# Append to PROMPT_COMMAND to emit sequences just before each prompt
|
||||||
if [ -z "$PROMPT_COMMAND" ]; then
|
if [ -z "$PROMPT_COMMAND" ]; then
|
||||||
PROMPT_COMMAND="__cmder_prompt_command"
|
PROMPT_COMMAND="__cmder_prompt_command"
|
||||||
else
|
else
|
||||||
@@ -76,8 +72,15 @@ else
|
|||||||
trap '__cmder_preexec' DEBUG
|
trap '__cmder_preexec' DEBUG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Source: github.com/git-for-windows/build-extra/blob/main/git-extra/git-prompt.sh
|
||||||
PS1='\[\033]0;${TITLEPREFIX:+$TITLEPREFIX:}${PWD//[^[:ascii:]]/?}\007\]' # set window title to TITLEPREFIX (if set) and current working directory
|
PS1='\[\033]0;${TITLEPREFIX:+$TITLEPREFIX:}${PWD//[^[:ascii:]]/?}\007\]' # set window title to TITLEPREFIX (if set) and current working directory
|
||||||
# PS1="$PS1"'\n' # new line (disabled)
|
# PS1="$PS1"'\n' # new line (disabled)
|
||||||
|
|
||||||
|
if [ -n "$WT_SESSION" ]; then
|
||||||
|
# Emit OSC 133;A to mark the start of prompt
|
||||||
|
PS1="$PS1"'\e]133;A\a'
|
||||||
|
fi
|
||||||
|
|
||||||
PS1="$PS1"'\[\033[32m\]' # change to green and bold
|
PS1="$PS1"'\[\033[32m\]' # change to green and bold
|
||||||
PS1="$PS1"'\u@\h ' # user@host<space>
|
PS1="$PS1"'\u@\h ' # user@host<space>
|
||||||
PS1="$PS1${MSYSTEM:+\[\033[35m\]$MSYSTEM }" # show MSYSTEM in purple (if set)
|
PS1="$PS1${MSYSTEM:+\[\033[35m\]$MSYSTEM }" # show MSYSTEM in purple (if set)
|
||||||
@@ -109,8 +112,8 @@ else
|
|||||||
PS1="$PS1"'λ ' # prompt: Cmder uses λ
|
PS1="$PS1"'λ ' # prompt: Cmder uses λ
|
||||||
PS1="$PS1"'\[\033[0m\]' # reset color
|
PS1="$PS1"'\[\033[0m\]' # reset color
|
||||||
|
|
||||||
# OSC 133;B - Mark start of command input (Windows Terminal only)
|
|
||||||
if [ -n "$WT_SESSION" ]; then
|
if [ -n "$WT_SESSION" ]; then
|
||||||
|
# Emit OSC 133;B to mark the end of prompt
|
||||||
PS1="$PS1"'\[\e]133;B\a\]'
|
PS1="$PS1"'\[\e]133;B\a\]'
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
17
vendor/profile.ps1
vendored
17
vendor/profile.ps1
vendored
@@ -98,8 +98,7 @@ if (Get-Module PSReadline -ErrorAction "SilentlyContinue") {
|
|||||||
# Display an extra prompt line between the prompt and the command input
|
# Display an extra prompt line between the prompt and the command input
|
||||||
Set-PSReadlineOption -ExtraPromptLineCount 1
|
Set-PSReadlineOption -ExtraPromptLineCount 1
|
||||||
|
|
||||||
# Add OSC 133;C support for Windows Terminal shell integration
|
# Invoked when Enter is pressed to submit a command
|
||||||
# This marks the start of command output (emitted when Enter is pressed)
|
|
||||||
if ($env:WT_SESSION) {
|
if ($env:WT_SESSION) {
|
||||||
Set-PSReadLineKeyHandler -Key Enter -ScriptBlock {
|
Set-PSReadLineKeyHandler -Key Enter -ScriptBlock {
|
||||||
# Get the current command line
|
# Get the current command line
|
||||||
@@ -110,7 +109,7 @@ if (Get-Module PSReadline -ErrorAction "SilentlyContinue") {
|
|||||||
# Accept the line first
|
# Accept the line first
|
||||||
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
|
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
|
||||||
|
|
||||||
# Emit OSC 133;C sequence to mark start of command output
|
# Emit OSC 133;C to mark start of command output
|
||||||
# This is written directly to the console after the command is accepted
|
# This is written directly to the console after the command is accepted
|
||||||
[Console]::Write("$([char]0x1B)]133;C$([char]7)")
|
[Console]::Write("$([char]0x1B)]133;C$([char]7)")
|
||||||
}
|
}
|
||||||
@@ -221,20 +220,22 @@ if ( $(Get-Command prompt).Definition -match 'PS \$\(\$executionContext.SessionS
|
|||||||
$lastSUCCESS = $?
|
$lastSUCCESS = $?
|
||||||
$realLastExitCode = $LastExitCode
|
$realLastExitCode = $LastExitCode
|
||||||
|
|
||||||
# Emit terminal-specific escape sequences for Windows Terminal and ConEmu
|
# Terminal-specific escape sequences for Windows Terminal and ConEmu
|
||||||
if ($env:WT_SESSION -or $env:ConEmuPID) {
|
if ($env:WT_SESSION -or $env:ConEmuPID) {
|
||||||
# OSC 133;D - Mark end of command execution with exit code (Windows Terminal only)
|
# Emit OSC 133;D to mark the end of command execution with exit code
|
||||||
if ($env:WT_SESSION) {
|
if ($env:WT_SESSION) {
|
||||||
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]133;D;$realLastExitCode$([char]7)"
|
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]133;D;$realLastExitCode$([char]7)"
|
||||||
}
|
}
|
||||||
|
|
||||||
# OSC 9;9 - Enable directory tracking for "Duplicate Tab" and "Split Pane"
|
# Emit OSC 9;9 to mark the start of the prompt
|
||||||
|
# Enables directory tracking for "Duplicate Tab" and "Split Pane"
|
||||||
$loc = $executionContext.SessionState.Path.CurrentLocation
|
$loc = $executionContext.SessionState.Path.CurrentLocation
|
||||||
if ($loc.Provider.Name -eq "FileSystem") {
|
if ($loc.Provider.Name -eq "FileSystem") {
|
||||||
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]9;9;`"$($loc.ProviderPath)`"$([char]0x1B)\"
|
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]9;9;`"$($loc.ProviderPath)`"$([char]0x1B)\"
|
||||||
}
|
}
|
||||||
|
|
||||||
# OSC 133;A - Mark start of prompt (Windows Terminal only)
|
# Emit OSC 133;A to mark the start of the prompt
|
||||||
|
# Enables features like command navigation, selection, and visual separators
|
||||||
if ($env:WT_SESSION) {
|
if ($env:WT_SESSION) {
|
||||||
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]133;A$([char]7)"
|
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]133;A$([char]7)"
|
||||||
}
|
}
|
||||||
@@ -249,7 +250,7 @@ if ( $(Get-Command prompt).Definition -match 'PS \$\(\$executionContext.SessionS
|
|||||||
CmderPrompt
|
CmderPrompt
|
||||||
PostPrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline
|
PostPrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline
|
||||||
|
|
||||||
# OSC 133;B - Mark start of command input (Windows Terminal only)
|
# Emit OSC 133;B to mark the start of command input (after prompt, before user types)
|
||||||
if ($env:WT_SESSION) {
|
if ($env:WT_SESSION) {
|
||||||
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]133;B$([char]7)"
|
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]133;B$([char]7)"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user