Windows Terminal 同一路径/复制/拆分标签页


  1. Tutorial: Opening a tab/pane in the same directory in Windows Terminal
  2. Open new terminal tab in same directory as existing tab (OSC 7?) #3158

For CMD

set PROMPT=$e]9;9;$P$e\%PROMPT%
setx PROMPT %PROMPT%

For Powershell

编辑$PROFILE(notepad $PROFILE)对应的配置文件,加入

function prompt {
  $loc = $($executionContext.SessionState.Path.CurrentLocation);
  $out = "PS $loc$('>' * ($nestedPromptLevel + 1)) ";
  $out += "$([char]27)]9;9;`"$loc`"$([char]27)\"
  return $out
}

如果使用了on-my-posh

PowerShell with posh-git

改为加入

function prompt
{
  $loc = Get-Location
  $prompt = & $GitPromptScriptBlock
  $prompt += "$([char]27)]9;12$([char]7)"
  if ($loc.Provider.Name -eq "FileSystem")
  {
    $prompt += "$([char]27)]9;9;`"$($loc.Path)`"$([char]7)"
  }
  $prompt
}

For WSL