Skip to content

Commit ced6aef

Browse files
committed
Update settings.json code block for shell integration
Based on the current schema (and messing with my own personal WT `settings.json`), it looks like declaring an `id` bound to defined `actions` & then referencing this id in `keybindings` is preferred over using the `keys` prop within elements of the `actions` array.
1 parent d70676d commit ced6aef

File tree

1 file changed

+35
-28
lines changed

1 file changed

+35
-28
lines changed

TerminalDocs/tutorials/shell-integration.md

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -58,33 +58,40 @@ Supporting these features requires cooperation between your shell and the Termin
5858
To enable these features in the Terminal, you'll want to add the following to your settings:
5959

6060
```json
61-
"profiles":
62-
{
63-
"defaults":
64-
{
65-
// Enable marks on the scrollbar
66-
"showMarksOnScrollbar": true,
67-
68-
// Needed for both pwsh, CMD and bash shell integration
69-
"autoMarkPrompts": true,
70-
71-
// Add support for a right-click context menu
72-
// You can also just bind the `showContextMenu` action
73-
"experimental.rightClickContextMenu": true,
74-
},
75-
}
76-
"actions":
77-
[
78-
// Scroll between prompts
79-
{ "keys": "ctrl+up", "command": { "action": "scrollToMark", "direction": "previous" }, },
80-
{ "keys": "ctrl+down", "command": { "action": "scrollToMark", "direction": "next" }, },
81-
82-
// Add the ability to select a whole command (or its output)
83-
{ "command": { "action": "selectOutput", "direction": "prev" }, },
84-
{ "command": { "action": "selectOutput", "direction": "next" }, },
85-
86-
{ "command": { "action": "selectCommand", "direction": "prev" }, },
87-
{ "command": { "action": "selectCommand", "direction": "next" }, },
61+
"profiles": {
62+
"defaults": {
63+
// Enable marks on the scrollbar
64+
"showMarksOnScrollbar": true,
65+
66+
// Needed for both pwsh, CMD and bash shell integration
67+
"autoMarkPrompts": true,
68+
69+
// Add support for a right-click context menu
70+
// You can also just bind the `showContextMenu` action
71+
"experimental.rightClickContextMenu": true,
72+
},
73+
},
74+
"actions": [
75+
// Create actions for scrolling to previous/next mark
76+
{ "command": { "action": "scrollToMark", "direction": "previous" }, "id": "Terminal.ScrollToPreviousMark" },
77+
{ "command": { "action": "scrollToMark", "direction": "next" }, "id": "Terminal.ScrollToNextMark" },
78+
// Create actions for selecting command(s) at previous/next mark(s)
79+
{ "command": { "action": "selectCommand", "direction": "prev" }, "id": "Terminal.SelectPrevCommand" },
80+
{ "command": { "action": "selectCommand", "direction": "next" }, "id": "Terminal.SelectNextCommand" },
81+
// Create actions for selecting output(s) from previous/next command(s)
82+
{ "command": { "action": "selectOutput", "direction": "prev" }, "id": "Terminal.SelectPrevOutput" },
83+
{ "command": { "action": "selectOutput", "direction": "next" }, "id": "Terminal.SelectNextOutput" },
84+
],
85+
"keybindings": [
86+
// Define hotkeys/shortcuts for these actions by referencing the prior (user-)assigned IDs
87+
{ "id": "Terminal.ScrollToPreviousMark", "keys": "ctrl+up" },
88+
{ "id": "Terminal.ScrollToNextMark", "keys": "ctrl+down" },
89+
90+
{ "id": "Terminal.SelectPrevCommand", "keys": "ctrl+alt+shift+up" },
91+
{ "id": "Terminal.SelectNextCommand", "keys": "ctrl+alt+shift+down" },
92+
93+
{ "id": "Terminal.SelectPrevOutput", "keys": "ctrl+shift+up" },
94+
{ "id": "Terminal.SelectNextOutput", "keys": "ctrl+shift+down" }
8895
]
8996
```
9097

@@ -183,7 +190,7 @@ function prompt {
183190
$loc = $($executionContext.SessionState.Path.CurrentLocation);
184191
$out += "`e]133;A$([char]07)";
185192
$out += "`e]9;9;`"$loc`"$([char]07)";
186-
193+
187194
$out += $Global:__OriginalPrompt.Invoke(); # <-- This line adds the original prompt back
188195
189196
$out += "`e]133;B$([char]07)";

0 commit comments

Comments
 (0)