Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions TerminalDocs/tutorials/new-tab-same-directory.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,17 @@ Windows Subsystem for Linux distributions primarily use BASH as the command line

#### `bash`

Add the following line to the end of your `.bash_profile` config file:
Add the following line to the end of your `.bashrc` config file:

```bash
PROMPT_COMMAND=${PROMPT_COMMAND:+"$PROMPT_COMMAND ; "}'printf "\e]9;9;%s\e\\" "$(wslpath -w "$PWD")"'
PROMPT_COMMAND=${PROMPT_COMMAND:+"$PROMPT_COMMAND; "}'printf "\e]9;9;%s\e\\" "$(wslpath -w "$PWD")"'
```

The `PROMPT_COMMAND` variable in bash tells bash what command to run before displaying the prompt. The `printf` statement is what we're using to append the sequence for setting the working directory with the Terminal. The `$(wslpath -w "$PWD")` bit will invoke the `wslpath` executable to convert the current directory into its Windows-like path. The `${PROMPT_COMMAND:+"$PROMPT_COMMAND; "}` bit is [some bash magic](https://unix.stackexchange.com/a/466100) to make sure we append this command to any existing command (if you've already set `PROMPT_COMMAND` somewhere else.)

> [!NOTE]
> We recommend using `.bashrc` rather than `.bash_profile` because most terminal sessions (including new tabs and panes in Windows Terminal) start as non-login shells, which only read `.bashrc`. If you need this to work in login shells as well, you can add the same line to `.bash_profile`, or have `.bash_profile` source `.bashrc`.

#### `zsh`

Add the following lines to the end of your `.zshrc` file:
Expand Down