Git Bash prompt configuration for Windows Terminal¶
To enable the feature of opening a new tab or pane in the same directory within Windows Terminal when using Git Bash, the PROMPT_COMMAND environment variable must be configured to emit the current working directory path as an escape sequence.^[windows.md]
Bash Configuration¶
For Git Bash (which uses ~/.bash_profile or ~/.bashrc), the configuration involves appending a printf command to PROMPT_COMMAND.^[windows.md] This command uses the escape sequence \e]9;9;%s\e\\ combined with wslpath -w "$PWD" to format the path correctly for the Windows Terminal.^[windows.md]
bash
PROMPT_COMMAND=${PROMPT_COMMAND:+"$PROMPT_COMMAND; "}'printf "\e]9;9;%s\e\\" "$(wslpath -w "$PWD")"'^[windows.md]
Related Concepts¶
- [[Windows Terminal]]
- [[Bash profile]]
Sources¶
windows.md