Skip to content

Commit

Permalink
Add support up to 0.5.2661 (#41)
Browse files Browse the repository at this point in the history
Profiles

* Adds support for changing GUID
* Adds support for source property
* Adds support for hidden property

Global

* Adds support for disabledProfileSources
  • Loading branch information
gpduck authored Sep 25, 2019
1 parent ac60d72 commit 6c8c84b
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 19 deletions.
61 changes: 54 additions & 7 deletions docs/en-US/New-MSTerminalProfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ New-MSTerminalProfile [-Name] <String> [-CommandLine] <String> [-MakeDefault] [[
[[-CursorShape] <String>] [[-CursorHeight] <Int32>] [[-FontFace] <String>] [[-StartingDirectory] <String>]
[[-FontSize] <Int32>] [[-Background] <String>] [[-Foreground] <String>] [[-AcrylicOpacity] <Single>]
[-UseAcrylic] [[-BackgroundImage] <String>] [[-BackgroundImageAlignment] <String>]
[[-BackgroundImageOpacity] <Double>] [[-BackgroundImageStretchMode] <String>] [[-ScrollbarState] <String>]
[[-TabTitle] <String>] [-CloseOnExit] [[-Icon] <String>] [[-Padding] <Int32[]>] [[-ExtraSettings] <Hashtable>]
[-WhatIf] [-Confirm] [<CommonParameters>]
[[-BackgroundImageOpacity] <Double>] [[-BackgroundImageStretchMode] <String>] [-Hidden]
[[-ScrollbarState] <String>] [[-Source] <String>] [[-Guid] <Guid>] [[-TabTitle] <String>] [-CloseOnExit]
[[-Icon] <String>] [[-Padding] <Int32[]>] [[-ExtraSettings] <Hashtable>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -266,7 +267,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 22
Position: 24
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Expand Down Expand Up @@ -317,6 +318,36 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -Guid
A new GUID to uniquely identify this profile.
```yaml
Type: Guid
Parameter Sets: (All)
Aliases:

Required: False
Position: 20
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Hidden
If set to true, the profile will not appear in the list of profiles. This can be used to hide default profiles and dynamicially generated profiles, while leaving them in your settings file.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -HistorySize
The number of lines of history to store.
Expand All @@ -341,7 +372,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 20
Position: 22
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Expand Down Expand Up @@ -386,7 +417,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 21
Position: 23
Default value: 0,0,0,0
Accept pipeline input: False
Accept wildcard characters: False
Expand Down Expand Up @@ -423,6 +454,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -Source
The source for dynamically generated profiles.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Accepted values: Windows.Terminal.Azure, Windows.Terminal.PowershellCore, Windows.Terminal.Wsl

Required: False
Position: 19
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -StartingDirectory
The working directory to start in.
Expand All @@ -447,7 +494,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 19
Position: 21
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Expand Down
58 changes: 52 additions & 6 deletions docs/en-US/Set-MSTerminalProfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Set-MSTerminalProfile -Name <String> [-CommandLine <String>] [-MakeDefault] [-Hi
[-CursorShape <String>] [-CursorHeight <Int32>] [-FontFace <String>] [-StartingDirectory <String>]
[-FontSize <Int32>] [-Background <String>] [-Foreground <String>] [-AcrylicOpacity <Single>] [-UseAcrylic]
[-BackgroundImage <String>] [-BackgroundImageAlignment <String>] [-BackgroundImageOpacity <Double>]
[-BackgroundImageStretchMode <String>] [-ScrollbarState <String>] [-TabTitle <String>] [-CloseOnExit]
[-Icon <String>] [-Padding <Int32[]>] [-Clear <String[]>] [-ExtraSettings <Hashtable>] [-WhatIf] [-Confirm]
[<CommonParameters>]
[-BackgroundImageStretchMode <String>] [-Hidden] [-ScrollbarState <String>] [-Source <String>]
[-NewGuid <Guid>] [-TabTitle <String>] [-CloseOnExit] [-Icon <String>] [-Padding <Int32[]>]
[-Clear <String[]>] [-ExtraSettings <Hashtable>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### InputObject
Expand All @@ -31,9 +31,9 @@ Set-MSTerminalProfile -InputObject <Object> [-CommandLine <String>] [-MakeDefaul
[-CursorShape <String>] [-CursorHeight <Int32>] [-FontFace <String>] [-StartingDirectory <String>]
[-FontSize <Int32>] [-Background <String>] [-Foreground <String>] [-AcrylicOpacity <Single>] [-UseAcrylic]
[-BackgroundImage <String>] [-BackgroundImageAlignment <String>] [-BackgroundImageOpacity <Double>]
[-BackgroundImageStretchMode <String>] [-ScrollbarState <String>] [-TabTitle <String>] [-CloseOnExit]
[-Icon <String>] [-Padding <Int32[]>] [-Clear <String[]>] [-ExtraSettings <Hashtable>] [-WhatIf] [-Confirm]
[<CommonParameters>]
[-BackgroundImageStretchMode <String>] [-Hidden] [-ScrollbarState <String>] [-Source <String>]
[-NewGuid <Guid>] [-TabTitle <String>] [-CloseOnExit] [-Icon <String>] [-Padding <Int32[]>]
[-Clear <String[]>] [-ExtraSettings <Hashtable>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -346,6 +346,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -Hidden
If set to true, the profile will not appear in the list of profiles. This can be used to hide default profiles and dynamicially generated profiles, while leaving them in your settings file.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -HistorySize
The number of lines of history to store.
Expand Down Expand Up @@ -421,6 +436,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -NewGuid
A new GUID to use to identify this profile.
```yaml
Type: Guid
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Padding
The padding to use between the window edges and the text.
Expand Down Expand Up @@ -467,6 +497,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -Source
The source for dynamically generated profiles.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Accepted values: Windows.Terminal.Azure, Windows.Terminal.PowershellCore, Windows.Terminal.Wsl,

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -StartingDirectory
The working directory to start in.
Expand Down
24 changes: 20 additions & 4 deletions docs/en-US/Set-MSTerminalSetting.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Updates the top-level settings for MS Terminal.
```
Set-MSTerminalSetting [[-DefaultProfile] <String>] [[-InitialRows] <Int32>] [[-InitialCols] <Int32>]
[-AlwaysShowTabs] [[-RequestedTheme] <String>] [-ShowTerminalTitleInTitlebar] [-ShowTabsInTitlebar]
[[-WordDelimiters] <String>] [-CopyOnSelect] [[-Clear] <String[]>] [[-ExtraSettings] <Hashtable>] [-WhatIf]
[-Confirm] [<CommonParameters>]
[[-WordDelimiters] <String>] [-CopyOnSelect] [[-DisabledProfileSources] <String[]>] [[-Clear] <String[]>]
[[-ExtraSettings] <Hashtable>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -57,7 +57,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 5
Position: 6
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Expand Down Expand Up @@ -110,6 +110,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -DisabledProfileSources
A list of dynamic profile sources to disable. This will hide all dynamic profiles created by that source.
```yaml
Type: String[]
Parameter Sets: (All)
Aliases:
Accepted values: Windows.Terminal.Azure, Windows.Terminal.PowershellCore, Windows.Terminal.Wsl

Required: False
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ExtraSettings
{{ Fill ExtraSettings Description }}
Expand All @@ -119,7 +135,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 6
Position: 7
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Expand Down
16 changes: 15 additions & 1 deletion src/ExportedFunctions/New-MSTerminalProfile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,16 @@ function New-MSTerminalProfile {
[ValidateSet("none","fill","uniform","uniformToFill")]
[String]$BackgroundImageStretchMode,

[switch]$Hidden,

[ValidateSet("visible","hidden")]
[string]$ScrollbarState,

[ValidateSet("Windows.Terminal.Azure","Windows.Terminal.PowershellCore","Windows.Terminal.Wsl")]
[string]$Source,

[GUID]$Guid,

[string]$TabTitle,

[switch]$CloseOnExit = $true,
Expand Down Expand Up @@ -87,9 +94,14 @@ function New-MSTerminalProfile {
}
}

if(!$Guid) {
$Guid = [Guid]::NewGuid()
}
$GuidString = "{$Guid}"

$Profile = @{
name = $Name
guid = "{$([Guid]::NewGuid().Guid)}"
guid = $GuidString
commandline = $CommandLine
}
$Properties = @(
Expand All @@ -108,10 +120,12 @@ function New-MSTerminalProfile {
"fontFace",
"fontSize",
"foreground",
"hidden",
"historySize",
"icon",
"scrollbarState",
"snapOnInput",
"source",
"startingDirectory",
"tabTitle",
"useAcrylic"
Expand Down
16 changes: 15 additions & 1 deletion src/ExportedFunctions/Set-MSTerminalProfile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,16 @@ function Set-MSTerminalProfile {
[AllowNull()]
[String]$BackgroundImageStretchMode,

[switch]$Hidden,

[ValidateSet("visible","hidden")]
[string]$ScrollbarState,

[ValidateSet("Windows.Terminal.Azure","Windows.Terminal.PowershellCore","Windows.Terminal.Wsl","")]
[string]$Source,

[guid]$NewGuid,

[string]$TabTitle,

[switch]$CloseOnExit,
Expand Down Expand Up @@ -109,6 +116,7 @@ function Set-MSTerminalProfile {
"cursorColor",
"cursorShape",
"cursorHeight",
"hidden",
"historySize",
"fontFace",
"fontSize",
Expand All @@ -118,6 +126,7 @@ function Set-MSTerminalProfile {
"tabTitle",
"acrylicOpacity",
"snapOnInput",
"source",
"startingDirectory",
"useAcrylic",
"icon"
Expand Down Expand Up @@ -148,8 +157,13 @@ function Set-MSTerminalProfile {
$ProfileReplaced = $true
}

$OldGuid = $TerminalProfile['guid']
if($NewGuid) {
$TerminalProfile['guid'] = "{$NewGuid}"
}

$Settings["profiles"] = @($Settings["profiles"] | ForEach-Object {
if($_.guid -eq $TerminalProfile['guid']) {
if($_.guid -eq $OldGuid) {
if($PSCmdlet.ShouldProcess("$($_.name) $($_.guid)", "Replace profile")) {
$TerminalProfile
Write-Debug (ConvertTo-Json $TerminalProfile)
Expand Down
4 changes: 4 additions & 0 deletions src/ExportedFunctions/Set-MSTerminalSetting.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ function Set-MSTerminalSetting {

[switch]$CopyOnSelect,

[ValidateSet("Windows.Terminal.Azure","Windows.Terminal.PowershellCore","Windows.Terminal.Wsl","")]
[string[]]$DisabledProfileSources,

[string[]]$Clear,

[hashtable]$ExtraSettings = @{}
Expand All @@ -40,6 +43,7 @@ function Set-MSTerminalSetting {
"alwaysShowTabs",
"copyOnSelect",
"defaultProfile",
"disabledProfileSources",
"initialRows",
"initialCols",
"requestedTheme",
Expand Down
10 changes: 10 additions & 0 deletions test/New-MSTerminalProfile.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Describe "New-MSTerminalProfile" {
acrylicOpacity = 0.11
cursorShape = "vintage"
startingDirectory = "new-pester"
hidden = $true
source = "Windows.Terminal.PowershellCore"
Guid = "{$(([Guid]::NewGuid().Guid))}"
}
$SCRIPT:ExtraSettingValue1 = [Guid]::NewGuid().guid
$SCRIPT:ExtraSettingValue2 = [Guid]::NewGuid().guid
Expand Down Expand Up @@ -62,6 +65,11 @@ Describe "New-MSTerminalProfile" {
$After.Globals.defaultProfile | Should -Not -Be $Before.Globals.defaultProfile

}

It "Generates a guid when one is not provided" {
New-MSTerminalProfile -Name NoGuid -CommandLine NoGuid.exe
(Get-MSTerminalProfile -name NoGuid).Guid | Should -Not -Be $null
}
}

context "No existing profiles" {
Expand Down Expand Up @@ -90,6 +98,8 @@ Describe "New-MSTerminalProfile" {
acrylicOpacity = 0.11
cursorShape = "vintage"
startingDirectory = "new-pester"
hidden = $true
source = "Windows.Terminal.PowershellCore"
}
New-MSTerminalProfile @NewValues
$NewProfile = Get-MSTerminalProfile -Name new-pester
Expand Down
Loading

0 comments on commit 6c8c84b

Please sign in to comment.