Skip to content

Commit

Permalink
Toc update (#457)
Browse files Browse the repository at this point in the history
* Update to change equal symbol to plus key

Addresses issue #196
*On my Surface Book keyboard + and = are the same key, but this may not be the case for all keyboard layouts.

* change + to plus as shipped by default

* Add notes about title change persistance

* Update settings.json section

* Link settings.json mentions

* Fix links

* fix a few more links

* Update TerminalDocs/customize-settings/actions.md

Co-authored-by: Kayla Cinnamon <cinnamon@microsoft.com>

* Update TerminalDocs/dynamic-profiles.md

Co-authored-by: Kayla Cinnamon <cinnamon@microsoft.com>

* Update TerminalDocs/customize-settings/actions.md

Co-authored-by: Kayla Cinnamon <cinnamon@microsoft.com>

* Remove repititious section

* Added browser media keys (#371)

* Add link to what is command line shell video (#377)

* add intenseTextStyle to the docs (#381)

* Multiple new pane features (#383)

Documentation for 
- microsoft/terminal#10713
- microsoft/terminal#10638
- microsoft/terminal#10780
- microsoft/terminal#10927

* wt.exe --window argument now available (#388)

* Add notes that the `font` object is only 1.10+ (#389)

Co-authored-by: Kayla Cinnamon <cinnamon@microsoft.com>

* Remove MinimizeToTray action mentions (#387)

* Docs updates for 1.11 release (#397)

* Specify OS version availability for defterm (#417)

Co-authored-by: Kayla Cinnamon <cinnamon@microsoft.com>

* Remove tilde

Reshttps://github.com/MicrosoftDocs/terminal/issues/260olves

* Improve dup tab description

#292

* Update minimizetotray setting to new name

* Merge release 1.12 into master (#428)

Co-authored-by: Kayla Cinnamon <cinnamon@microsoft.com>
Co-authored-by: Pankaj Bhojwani <pabhojwa@microsoft.com>
Co-authored-by: Matt Wojciakowski <mattwoj@microsoft.com>
Co-authored-by: Mike Griese <migrie@microsoft.com>
Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
Co-authored-by: Schuyler Rosefield <Rosefield@users.noreply.github.com>
Co-authored-by: PankajBhojwani <pankaj.d.bhoj@gmail.com>

* Remove preview labels

* Add redirect for old powerline page

* Add vscode to gitignore

* Config changes to reflect the default branch from master to main.

* Add a note about the command palette to this doc (#447)

* Add details about the command used to print the table (#446)

* initialPos -> initialPosition (#445)

* Add tip on extensions for configuration files (#440)

* Add tip on extensions for configuration files

Resolves #423

* fix numbering

Co-authored-by: Matt Wojciakowski <mattwoj@microsoft.com>

* Corrected path (#434)

The LocalAppData path was missing `{app-name}`

* Update panes.md (#432)

Minor edit on a shortcut key

* Correct $PROFILE configuration (#431)

When using winget, Oh-my-posh will not add Set-PoshPrompt to path, the execution will fail. The correct configuration can be found in https://ohmyposh.dev/docs/windows#replace-your-existing-prompt

* Add a sample page (#444)

* Add FAQ page (#442)

* Add FAQ page

* Finalize faq v1

* Replace md with yml, add toc

* Update with settings UI feedback from kayla

* fix image link

* Fix preview faq

* Add a guide for using OSC9;9 (#449)

* I think this is everything we need. Pushing because I don't know if the image paths are right

* This should fix the warnings

* maybe fix the urls?

* typos

* Update TerminalDocs/tutorials/new-tab-same-directory.md

Co-authored-by: Felix Christl <fchristl@gmail.com>

Co-authored-by: Matt Wojciakowski <mattwoj@microsoft.com>
Co-authored-by: Felix Christl <fchristl@gmail.com>

* Minor quake mode text update (#454)

* DocuTune: Fix ms.topic values (#453)

Co-authored-by: Kayla Cinnamon <cinnamon@microsoft.com>
Co-authored-by: Floris Westerman <me@floriswesterman.nl>
Co-authored-by: Mike Griese <migrie@microsoft.com>
Co-authored-by: Schuyler Rosefield <Rosefield@users.noreply.github.com>
Co-authored-by: Sean Jacobs <Sophismata@users.noreply.github.com>
Co-authored-by: Leon Liang <lelian@microsoft.com>
Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
Co-authored-by: Pankaj Bhojwani <pabhojwa@microsoft.com>
Co-authored-by: PankajBhojwani <pankaj.d.bhoj@gmail.com>
Co-authored-by: Nivaldo Tokuda <ni.h1@hotmail.com>
Co-authored-by: David A. Sjøen <dasjoen@gmail.com>
Co-authored-by: tharindu sathischandra <34299693+tharindusathis@users.noreply.github.com>
Co-authored-by: Cutano <rinne@rinne.top>
Co-authored-by: Felix Christl <fchristl@gmail.com>
Co-authored-by: Alex Buck <abuck@microsoft.com>
  • Loading branch information
16 people committed Dec 10, 2021
1 parent b56dd2f commit 13d4fc4
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 2 deletions.
2 changes: 1 addition & 1 deletion TerminalDocs/dynamic-profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Learn about dynamic profiles in Windows Terminal.
author: cinnamon-msft
ms.author: cinnamon
ms.date: 08/30/2021
ms.topic: concept
ms.topic: conceptual
---

# Dynamic profiles in Windows Terminal
Expand Down
Binary file added TerminalDocs/images/duplicate-tab-same-cwd.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TerminalDocs/images/split-pane-same-cwd.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion TerminalDocs/tips-and-tricks.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ You can also use this functionality to run builds or test scripts.

* When [`windowingBehavior`](./customize-settings/startup.md#new-instance-behavior) is set to `"useExisting"` or `"useAnyExisting"`, they will ignore the existence of the `_quake` window.

* The window will be hidden from the taskbar and from <kbd>Alt</kbd>+<kbd>Tab</kbd>.
* When minimized, the window will be hidden from the taskbar and from <kbd>Alt</kbd>+<kbd>Tab</kbd>.

* Only one window may be the quake mode window at a time.

Expand Down
132 changes: 132 additions & 0 deletions TerminalDocs/tutorials/new-tab-same-directory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
title: Opening a tab/pane in the same directory
description: In this tutorial, you learn how to configure your shell to allow Windows Terminal to open tabs in the same path.
author: zadjii-msft
ms.author: migrie
ms.date: 11/18/2021
ms.topic: tutorial
#Customer intent: As a developer or IT admin, I want to open tabs in the same working directory as my current tab.
---

# Tutorial: Opening a tab/pane in the same directory in Windows Terminal

Typically, the "new tab" and "split pane" actions will always open a new tab/pane in whatever the `startingDirectory` is for that profile. However, on other platforms, it's common for new tabs to automatically use the working directory of the current tab as the starting directory for a new tab. This allows the user to quickly multitask in a single directory.

Unfortunately, on Windows, it's tricky to determine what the current working directory ("CWD") for a process is. Even if we were able to look it up, not all applications actually set their CWD as they navigate. Notably, Windows PowerShell doesn't change its CWD as you `cd` around the file system! Duplicating the CWD of PowerShell automatically would almost always be wrong.

Fortunately, there's a workaround. Applications can emit a special escape sequence to manually tell the Terminal what the CWD should be.

In this tutorial, you learn how to:

> [!div class="checklist"]
> * Configure the shell to tell the Terminal about it's current working directory
> * Use the `duplicateTab` action to open a tab with the same CWD
> * Use the `splitPane` action to open a pane with the same CWD
> * Using the tab context menu to open tabs or panes with the same CWD
## Configure your shell

To tell the Terminal what the CWD is, you'll need to modify your shell to emit an escape sequence as you navigate the OS. Fortunately, most shells have a mechanism for configuring the "prompt", which is run after every command. This is the perfect place to add such output.

### Windows

#### Command Prompt: `cmd.exe`

`cmd` uses the `%PROMPT%` environment variable to configure the prompt. You can easily prepend the prompt with the command to set the CWD with the following command:

```cmd
set PROMPT=$e]9;9;$P$e\%PROMPT%
```

This will append `$e]9;9;$P$e\` to your current prompt. When cmd evaluates this prompt, it'll replace
* the `$e` with the escape character
* the `$p` with the current working directory

Note that the above command will only work for the current `cmd.exe` session. To set the value permantently, AFTER running the above command, you'll want to run

```cmd
setx PROMPT %PROMPT%
```

#### PowerShell: `powershell.exe` or `pwsh.exe`

If you've never changed your PowerShell prompt before, you should check out [about_Prompts](/powershell/module/microsoft.powershell.core/about/about_prompts) first.

Add the following to your [PowerShell profile](/powershell/module/microsoft.powershell.core/about/about_profiles):

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

#### PowerShell with posh-git

If you're using posh-git, then that will already modify your prompt. In that case, you'll want to only add the necessary output to the already modified prompt. The following example is a lightly modified version of this example from [the ConEmu docs](https://conemu.github.io/en/ShellWorkDir.html#PowerShellPoshGit):

```powershell
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
}
```

### WSL

#### `bash`

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

```bash
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]
> Don't see your favorite shell here? If you figure it out, feel free to open a PR to contribute a solution for your preferred shell!
## Using actions to duplicate the path

Once you've got the shell configured to tell the Terminal what the current directory is, opening a new tab or pane with that path is easy.

### Open a new tab with `duplicateTab`

To open a new tab with the same path (and profile) as the currently active terminal, use the "Duplicate Tab" action. This is bound by default to <kbd>ctrl+shift+d</kbd>, as follows:

```json
{ "command": "duplicateTab", "keys": "ctrl+shift+d" },
```

(see [`duplicateTab`](../customize-settings/actions.md#duplicate-tab)) for more details.

### Open a new pane with `splitPane`

To open a new pane with the same path (and profile) as the currently active terminal, use the "Duplicate Pane" action. This is **NOT** bound by default. The simplest form of this action is:

```json
{ "command": { "action": "splitPane", "splitMode": "duplicate" } },
```

(see [`splitPane`](../customize-settings/actions.md#split-a-pane)) for more details.

## Using the menu to duplicate the path

the above actions are also available on the tab context menu, under the entries "Duplicate Tab" and "Split Pane".

[!duplicate-tab-same-cwd](../images/duplicate-tab-same-cwd.gif)
[!split-pane-same-cwd](../images/split-pane-same-cwd.gif)

0 comments on commit 13d4fc4

Please sign in to comment.