Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cascading User + Default Settings #2515

Merged
merged 54 commits into from
Sep 16, 2019
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
858341f
Create profiles by layering them
zadjii-msft Aug 20, 2019
2074ac2
Update test to layer multiple times on the same profile
zadjii-msft Aug 20, 2019
deb135f
Add support for layering an array of profiles, but break a couple tests
zadjii-msft Aug 20, 2019
e524ea7
Add a defaults.json to the package
zadjii-msft Aug 20, 2019
8157fd6
Layer colorschemes
zadjii-msft Aug 20, 2019
16336bb
Layer an array of color schemes
zadjii-msft Aug 20, 2019
870fed3
Merge remote-tracking branch 'origin/master' into dev/migrie/f/754-la…
zadjii-msft Aug 21, 2019
22e375d
oh no, this was missed with #2481
zadjii-msft Aug 21, 2019
4e3c3c3
Layer keybindings
zadjii-msft Aug 21, 2019
2c2fa14
Read settings from defaults.json + profiles.json, layer appropriately
zadjii-msft Aug 21, 2019
9bcf0c5
Add tests for keybindings
zadjii-msft Aug 21, 2019
c6b80b9
Layer or clear optional properties
zadjii-msft Aug 21, 2019
c040356
Add a helper to get an optional variable for a bunch of different types
zadjii-msft Aug 21, 2019
51bcf11
Do this with the stretch mode too
zadjii-msft Aug 21, 2019
8b938ff
Add back in the GUID check for profiles
zadjii-msft Aug 22, 2019
aec4c51
Add some tests for global settings layering
zadjii-msft Aug 22, 2019
1d662ca
M A D W I T H P O W E R
zadjii-msft Aug 22, 2019
9a14dab
When the user's profile.json doesn't exist, create it from a template
zadjii-msft Aug 22, 2019
82b57f8
Re-order profiles to match the order set in the user's profiles.json
zadjii-msft Aug 22, 2019
2084f89
Add tests for re-ordering profiles to match user ordering
zadjii-msft Aug 22, 2019
e07c1ba
Add support for hiding profiles using `"hidden": true`
zadjii-msft Aug 22, 2019
3ab0f25
Use the hardcoded defaults.json for the exception->"use defaults" case
zadjii-msft Aug 22, 2019
39b7fe1
Merge remote-tracking branch 'origin/master' into dev/migrie/f/754-la…
zadjii-msft Aug 22, 2019
9b6a2ee
Somehow I messed up the git submodules?
zadjii-msft Aug 22, 2019
be8e858
woo documentation
zadjii-msft Aug 22, 2019
7dcb179
Fix a Terminal.App.Unit.Tests failure
zadjii-msft Aug 23, 2019
7953e8c
signed/unsigned is hard
zadjii-msft Aug 23, 2019
2032b96
Use Alt+Settings button to open the default settings
zadjii-msft Aug 23, 2019
bf792e8
Missed a signed/unsigned
zadjii-msft Aug 23, 2019
215af70
Merge branch 'master' into dev/migrie/f/754-layer-settings
zadjii-msft Aug 26, 2019
48d3e76
Some very preliminary PR feedback
zadjii-msft Aug 26, 2019
679bf2e
More PR feedback
zadjii-msft Aug 26, 2019
2c978f7
Add templates to these bois
zadjii-msft Aug 26, 2019
9320304
remove some code for generating defaults, reorder defaults.json a tad
zadjii-msft Aug 26, 2019
083ac42
Merge branch 'master' into dev/migrie/f/754-layer-settings
zadjii-msft Aug 26, 2019
2278f22
Make guid a std::optional
zadjii-msft Aug 26, 2019
0873210
Large block of PR feedback
zadjii-msft Aug 27, 2019
e3171ea
stl is love, stl is life
zadjii-msft Aug 27, 2019
966ddeb
add `-noprofile`
zadjii-msft Aug 29, 2019
db6a734
Fix the crash that dustin found
zadjii-msft Aug 29, 2019
eea22cc
-Encoding ASCII
zadjii-msft Aug 29, 2019
a685bd8
Set a profile's default scheme to Campbell
zadjii-msft Aug 29, 2019
5e98b81
Fix the tests I regressed
zadjii-msft Aug 29, 2019
4eec81b
Update UsingJsonSetting.md to reflect that changes from these PRs
zadjii-msft Aug 29, 2019
ff1ad96
Change how GenerateGuidForProfile works
zadjii-msft Sep 3, 2019
54eb9c7
Merge branch 'master' into dev/migrie/f/754-layer-settings
zadjii-msft Sep 5, 2019
a659db1
Make AppKeyBindings do its own serialization
zadjii-msft Sep 5, 2019
a757b07
Remove leftover dead code from the previous commit
zadjii-msft Sep 5, 2019
46adadf
Fix up an enormous number of PR nits
zadjii-msft Sep 6, 2019
86aabba
Merge remote-tracking branch 'origin/master' into dev/migrie/f/754-la…
zadjii-msft Sep 11, 2019
edb1ead
Fix a typo; Update the defaults to match #2378
zadjii-msft Sep 11, 2019
fed6492
Tiny nits
zadjii-msft Sep 11, 2019
d1e98b6
Some typos, PR nits
zadjii-msft Sep 13, 2019
e454753
Fix this broken defaults case
zadjii-msft Sep 16, 2019
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
138 changes: 120 additions & 18 deletions doc/user-docs/UsingJsonSettings.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
# Editing Windows Terminal JSON Settings

One way (currently the only way) to configure Windows Terminal is by editing the profiles.json settings file. At
the time of writing you can open the settings file in your default editor by selecting
`Settings` from the WT pull down menu.
One way (currently the only way) to configure Windows Terminal is by editing the
`profiles.json` settings file. At the time of writing you can open the settings
file in your default editor by selecting `Settings` from the WT pull down menu.

The settings are stored in the file `$env:LocalAppData\Packages\Microsoft.WindowsTerminal_<randomString>\RoamingState\profiles.json`
The settings are stored in the file `$env:LocalAppData\Packages\Microsoft.WindowsTerminal_<randomString>\RoamingState\profiles.json`.

Details of specific settings can be found [here](../cascadia/SettingsSchema.md). A general introduction is provided below.
As of [#2515](https://github.com/microsoft/terminal/pull/2515), the settings are
split into _two_ files: a hardcoded `defaults.json`, and `profiles.json`, which
contains the user settings. Users should only be concerned with the contents of
the `profiles.json`, which contains their customizations. The `defaults.json`
file is only provided as a reference of what the default settings are. For more
details on how these two files work, see [Settings
Layering](#settings-layering). To view the default settings file, click on the
"Settings" button while holding the <kbd>Alt</kbd> key.

Details of specific settings can be found [here](../cascadia/SettingsSchema.md).
A general introduction is provided below.

The settings are grouped under four headings:

Expand All @@ -17,12 +27,13 @@ The settings are grouped under four headings:

## Global Settings

These settings define startup defaults.
These settings define startup defaults, and application-wide settings that might
not affect a particular terminal instance.

* Theme
* Title Bar options
* Initial size
* Default profile used when WT is started
* Default profile used when the Windows Terminal is started

Example settings include

Expand All @@ -31,10 +42,13 @@ Example settings include
"initialCols" : 120,
"initialRows" : 50,
"requestedTheme" : "system",
"keybinding" : []
"keybindings" : []
...
```

These global properties can exist either in the root json object, or in and
object under a root property `"globals"`.

## Key Bindings

This is an array of key chords and shortcuts to invoke various commands.
Expand All @@ -43,10 +57,29 @@ Each command can have more than one key binding.
NOTE: Key bindings is a subfield of the global settings and
key bindings apply to all profiles in the same manner.

For example, here's a sample of the default keybindings:

```json
{
"keybindings":
[
{ "command": "closePane", "keys": ["ctrl+shift+w"] },
{ "command": "copy", "keys": ["ctrl+shift+c"] },
{ "command": "newTab", "keys": ["ctrl+shift+t"] },
// etc.
]
}

```

## Profiles

A profile contains the settings applied when a new WT tab is opened. Each profile is identified by a GUID and contains
a number of other fields.
A profile contains the settings applied when a new WT tab is opened. Each
profile is identified by a GUID and contains a number of other fields.

> 👉 **Note**: The `guid` property is the unique identifier for a profile. If
> multiple profiles all have the same `guid` value, you may see unexpected
> behavior.

* Which command to execute on startup - this can include arguments.
* Starting directory
Expand Down Expand Up @@ -77,6 +110,14 @@ The profile GUID is used to reference the default profile in the global settings

The values for background image stretch mode are documented [here](https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.media.stretch)

### Hiding a profile

If you want to remove a profile from the list of profiles in the new tab
dropdown, but keep the profile around in your `profiles.json` file, you can add
the property `"hidden": true` to the profile's json. This can also be used to
remove the default `cmd` and PowerShell profiles, if the user does not wish to
see them.

## Color Schemes

Each scheme defines the color values to be used for various terminal escape sequences.
Expand All @@ -97,6 +138,62 @@ Each schema is identified by the name field. Examples include

The schema name can then be referenced in one or more profiles.

## Settings layering

The runtime settings are actually constructed from _three_ sources:
* The default settings, which are hardcoded into the application, and available
in `defaults.json`. This includes the default keybindings, color schemes, and
profiles for both Windows PowerShell and Command Prompt (`cmd.exe`).
* Dynamic Profiles, which are generated at runtime. These include Powershell
Core, the Azure Cloud Shell connector, and profiles for and WSL distros.
* The user settings from `profiles.json`.

Settings from each of these sources are "layered" upon the settings from
previous sources. In this manner, the user settings in `profiles.json` can
contain _only the changes from the default settings_. For example, if a user
would like to only change the color scheme of the default `cmd` profile to
"Solarized Dark", you could change your cmd profile to the following:

```js
{
// Make changes here to the cmd.exe profile
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"colorScheme": "Solarized Dark"
}
```

Here, we're know we're changing the `cmd` profile, because the `guid`
`"{0caa0dad-35be-5f56-a8ff-afceeeaa6101}"` is `cmd`'s unique GUID. Any profiles
with that GUID will all be treated as the same object. Any changes in that
profile will overwrite those from the defaults.

Similarly, you can overwrite settings from a color scheme by defining a color
scheme in `profiles.json` with the same name as a default color scheme.

If you'd like to unbind a keystroke that's bound to an action in the default
keybindings, you can set the `"command"` to `"unbound"` or `null`. This will
allow the keystroke to fallthough to the commandline application instead of
performing the default action.

### Dynamic Profiles

When dynamic profiles are created at runtime, they'll be added to the
`profiles.json` file. You can identify these profiles by the presence of a
`"source"` property. These profiles are tied to their source - if you uninstall
a linux distro, then the profile will remain in your `profiles.json` file, but
the profile will be hidden.

If you'd like to disable a particular dynamic profile source, you can add that
`source` to the global `"disabledProfileSources"` array. For example, if you'd
like to hide all the WSL profiles, you could add the following setting:

```json

"disabledProfileSources": ["Microsoft.Terminal.WSL"],
...

```

## Configuration Examples:

### Add a custom background to the WSL Debian terminal profile
Expand Down Expand Up @@ -127,15 +224,17 @@ then you should use the URI style path name given in the above example.
More information about UWP URI schemes [here](https://docs.microsoft.com/en-us/windows/uwp/app-resources/uri-schemes).
3. Instead of using a UWP URI you can use a:
1. URL such as
`http://open.esa.int/files/2017/03/Mayer_and_Bond_craters_seen_by_SMART-1-350x346.jpg`
`http://open.esa.int/files/2017/03/Mayer_and_Bond_craters_seen_by_SMART-1-350x346.jpg`
2. Local file location such as `C:\Users\Public\Pictures\openlogo.jpg`

### Adding Copy and Paste Keybindings
### Adding Copy and Paste Keybindings

As of [#1093](https://github.com/microsoft/terminal/pull/1093) (first available in Windows Terminal v0.3), the Windows Terminal now
supports copy and paste keyboard shortcuts. However, if you installed and ran
the terminal before that, you won't automatically get the new keybindings added
to your settings. If you'd like to add shortcuts for copy and paste, you can do so by inserting the following objects into your `globals.keybindings` array:
As of [#1093](https://github.com/microsoft/terminal/pull/1093) (first available
in Windows Terminal v0.3), the Windows Terminal now supports copy and paste
keyboard shortcuts. However, if you installed and ran the terminal before that,
you won't automatically get the new keybindings added to your settings. If you'd
like to add shortcuts for copy and paste, you can do so by inserting the
following objects into your `globals.keybindings` array:

```json
{ "command": "copy", "keys": ["ctrl+shift+c"] },
Expand Down Expand Up @@ -171,5 +270,8 @@ You can even set multiple keybindings for a single action if you'd like. For exa
will bind both <kbd>ctrl+shift+v</kbd> and
<kbd>shift+Insert</kbd> to `paste`.

Note: If you set your copy keybinding to `"ctrl+c"`, you'll only be able to send an interrupt to the commandline application using <kbd>Ctrl+C</kbd> when there's no text selection.
Additionally, if you set `paste` to `"ctrl+v"`, commandline applications won't be able to read a ctrl+v from the input. For these reasons, we suggest `"ctrl+shift+c"` and `"ctrl+shift+v"`
Note: If you set your copy keybinding to `"ctrl+c"`, you'll only be able to send
an interrupt to the commandline application using <kbd>Ctrl+C</kbd> when there's
no text selection. Additionally, if you set `paste` to `"ctrl+v"`, commandline
applications won't be able to read a ctrl+v from the input. For these reasons,
we suggest `"ctrl+shift+c"` and `"ctrl+shift+v"`
8 changes: 8 additions & 0 deletions src/cascadia/CascadiaPackage/CascadiaPackage.wapproj
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@
<Content Include="$(OpenConsoleDir)res\terminal\Wide310x150Logo.scale-400.png">
<Link>Images\Wide310x150Logo.scale-400.png</Link>
</Content>
<!-- Profile Icons -->
<Content Include="ProfileIcons\{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.scale-100.png" />
<Content Include="ProfileIcons\{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.scale-200.png" />
<Content Include="ProfileIcons\{574e775e-4f2a-5b96-ac1e-a2962a402336}.scale-100.png" />
Expand All @@ -259,9 +260,16 @@
<Content Include="ProfileIcons\{9acb9455-ca41-5af7-950f-6bca1bc9722f}.scale-200.png" />
<Content Include="ProfileIcons\{b453ae62-4e3d-5e58-b989-0a998ec441b8}.scale-100.png" />
<Content Include="ProfileIcons\{b453ae62-4e3d-5e58-b989-0a998ec441b8}.scale-200.png" />
<!-- Default Settings -->
<Content Include="$(OpenConsoleDir)src\cascadia\TerminalApp\defaults.json">
<Link>defaults.json</Link>
</Content>
<!-- Resources -->
<PRIResource Include="Resources\en-US\Resources.resw" />
</ItemGroup>

<Import Project="$(OpenConsoleDir)src\wap-common.build.post.props" />

<ItemGroup>
<ProjectReference Include="..\WindowsTerminal\WindowsTerminal.vcxproj" />
<ProjectReference Include="..\..\host\exe\Host.EXE.vcxproj" />
Expand Down
Loading