Skip to content

Instantly share code, notes, and snippets.

@mlabrkic
Last active August 21, 2023 16:21
Show Gist options
  • Save mlabrkic/cc571623d32a8a81f689d57f6b9f0b1a to your computer and use it in GitHub Desktop.
Save mlabrkic/cc571623d32a8a81f689d57f6b9f0b1a to your computer and use it in GitHub Desktop.
"Windows Terminal"
## Windows Terminal
https://learn.microsoft.com/en-us/windows/terminal/
------------------------------------------------------------
### How to use the command palette in Windows Terminal
https://learn.microsoft.com/en-us/windows/terminal/command-palette
You can invoke the command palette by typing Ctrl+Shift+P.
------------------------------
#### Command line mode
https://learn.microsoft.com/en-us/windows/terminal/command-palette#command-line-mode
If you'd like to enter a wt command into the command palette,
you can do so by deleting the > character in the text box.
This will run the wt command in the current window.
Command Palette (Ctrl+Shift+P):
split-pane
split-pane cmd /k dir
split-pane "wsl.exe"
------------------------------
#### Nested commands
https://learn.microsoft.com/en-us/windows/terminal/command-palette#nested-commands
JSON
{
"name": "F- Change font size...",
"commands": [
{ "command": { "action": "adjustFontSize", "delta": 1 } },
{ "command": { "action": "adjustFontSize", "delta": -1 } },
{ "command": "resetFontSize" },
]
},
{
"name": "P- Pane ...",
"commands": [
{ "command": { "action": "splitPane", "split": "vertical" }, "keys": "alt+shift+plus" },
{ "command": { "action": "splitPane", "split": "horizontal" }, "keys": "alt+shift+-" },
{ "command": { "action": "moveFocus", "direction": "right" }, "keys": "alt+right" },
{ "command": { "action": "moveFocus", "direction": "left" }, "keys": "alt+left" },
{ "command": { "action": "swapPane", "direction": "right" } },
{ "command": { "action": "swapPane", "direction": "left" } },
{ "command": "toggleSplitOrientation" },
{ "command": { "action": "resizePane", "direction": "left" }, "keys": "alt+shift+left" },
{ "command": { "action": "resizePane", "direction": "right" }, "keys": "alt+shift+right" },
{ "command": "closePane", "keys": "ctrl+shift+w" },
{ "command": "togglePaneZoom", "keys": "ctrl+f11" },
{ "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" },
]
}
------------------------------------------------------------
------------------------------------------------------------
### Windows Terminal panes
https://learn.microsoft.com/en-us/windows/terminal/panes
------------------------------
#### Creating a new pane
To create a new vertical pane of your default profile,
you can press the Alt+Shift++ key combination.
(alt+shift+plus)
For a horizontal pane of your default profile,
you can use Alt+Shift+-.
{ "command": { "action": "splitPane", "split": "vertical" }, "keys": "alt+shift+plus" },
{ "command": { "action": "splitPane", "split": "horizontal" }, "keys": "alt+shift+-" },
or
Command Palette (Ctrl+Shift+P):
splitPane
spr(ight)
------------------------------
#### Switching between panes
https://learn.microsoft.com/en-us/windows/terminal/panes#switching-between-panes
If you hold the Alt key, you can use your arrow keys to move your focus between panes.
{ "command": { "action": "moveFocus", "direction": "down" }, "keys": "alt+down" },
{ "command": { "action": "moveFocus", "direction": "left" }, "keys": "alt+left" },
Alt+Right
Alt+Left
...
------------------------------
#### Swapping panes
https://learn.microsoft.com/en-us/windows/terminal/panes#swapping-panes
{ "command": { "action": "swapPane", "direction": "down" } },
{ "command": { "action": "swapPane", "direction": "left" } },
Command Palette (Ctrl+Shift+P):
swapPane
swr(ight)
swl(eft)
------------------------------
#### Moving panes
https://learn.microsoft.com/en-us/windows/terminal/panes#moving-panes
Panes can also be moved between tabs,
creating a new tab if one with the target index does not exist.
Command Palette (Ctrl+Shift+P):
movePane
mp1
------------------------------
#### Changing split orientation
https://learn.microsoft.com/en-us/windows/terminal/panes#changing-split-orientation
{ "command": "toggleSplitOrientation" }
Command Palette (Ctrl+Shift+P):
toggleSplitOrientation
togor
------------------------------
#### Resizing a pane
https://learn.microsoft.com/en-us/windows/terminal/panes#resizing-a-pane
You can adjust the size of your panes by holding Alt+Shift and
using your arrow keys to resize the focused pane.
JSON
{ "command": { "action": "resizePane", "direction": "down" }, "keys": "alt+shift+down" },
{ "command": { "action": "resizePane", "direction": "left" }, "keys": "alt+shift+left" },
{ "command": { "action": "resizePane", "direction": "right" }, "keys": "alt+shift+right" },
{ "command": { "action": "resizePane", "direction": "up" }, "keys": "alt+shift+up" }
------------------------------
#### Closing a pane
https://learn.microsoft.com/en-us/windows/terminal/panes#closing-a-pane
{ "command": "closePane", "keys": "ctrl+shift+w" }
------------------------------
#### Zooming a pane
https://learn.microsoft.com/en-us/windows/terminal/panes#zooming-a-pane
You can zoom the focused pane to fill the entire contents of the window.
JSON
{ "command": "togglePaneZoom", "keys": "ctrl+f11" },
The togglePaneZoom action is not bound to any keys by default.
------------------------------------------------------------
### Customizing panes using key bindings
------------------------------
#### Duplicating a pane
https://learn.microsoft.com/en-us/windows/terminal/panes#duplicating-a-pane
{ "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }
Duplicate pane
"alt+shift+d"
Duplicate tab
"Ctrl+shift+d"
------------------------------
#### Color a tab
https://learn.microsoft.com/en-us/windows/terminal/tips-and-tricks#color-a-tab
The tabColor can be set as part of a profile.
{
"font":
{
"size": 14.0
},
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"hidden": false,
"name": "PowerShell",
"source": "Windows.Terminal.PowershellCore",
"startingDirectory": "%USERPROFILE%\\Documents",
"tabColor": "#012456",
},
------------------------------------------------------------
### Mouse interaction
https://learn.microsoft.com/en-us/windows/terminal/tips-and-tricks#mouse-interaction
Info:
https://www.linuxhelp.com/how-to-install-midnight-commander-in-linux
------------------------------
#### Drag and drop file/folder to open
https://learn.microsoft.com/en-us/windows/terminal/tips-and-tricks#drag-and-drop-filefolder-to-open
You can hold Alt to open a new pane in your current tab or hold Shift to open a new window.
------------------------------
#### Clear your screen
https://learn.microsoft.com/en-us/windows/terminal/tips-and-tricks#clear-your-screen
Command Palette (Ctrl+Shift+P):
clear
cl
------------------------------
Navigate to parent directory
https://learn.microsoft.com/en-us/windows/terminal/tips-and-tricks#navigate-to-parent-directory
Navigating to the parent directory with a key binding may also be helpful.
JSON
{ "command": {"action": "sendInput", "input": "cd ..\r"}, "keys": "ctrl+up" }
{ "command": {"action": "sendInput", "input": "cd $HOME\\Documents\r"}, "keys": "ctrl+up" },
{ "command": {"action": "sendInput", "input": "cd /mnt/c/MB_PROJECTS\r"}, "keys": "ctrl+down" },
{ "command": {"action": "sendInput", "input": "cd %USERPROFILE%\\Documents\r"}, "keys": "ctrl+down" },
You can also use this functionality to run builds or test scripts.
------------------------------
############################################################
------------------------------------------------------------
https://learn.microsoft.com/en-us/windows/terminal/tutorials/new-tab-same-directory
------------------------------
Duplicate Windows Command Prompt (new-tab-same-directory):
Ctrl-Shift-d
Windows Command Prompt:
set PROMPT=$e]9;9;$P$e\%PROMPT%
setx PROMPT "%PROMPT%"
------------------------------------------------------------
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7.3
------------------------------
For example, the $PROFILE variable has the following values in the Windows PowerShell console.
Current User, Current Host - $PROFILE
Current User, Current Host - $PROFILE.CurrentUserCurrentHost
Current User, All Hosts - $PROFILE.CurrentUserAllHosts
All Users, Current Host - $PROFILE.AllUsersCurrentHost
All Users, All Hosts - $PROFILE.AllUsersAllHosts
------------------------------
To see the current values of the $PROFILE variable, type:
$PROFILE | Select-Object *
AllUsersAllHosts : C:\Program Files\PowerShell\7\profile.ps1
AllUsersCurrentHost : C:\Program Files\PowerShell\7\Microsoft.PowerShell_profile.ps1
CurrentUserAllHosts : %USERPROFILE%\Documents\PowerShell\profile.ps1
CurrentUserCurrentHost : %USERPROFILE%\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
Length : 70
------------------------------
notepad $PROFILE
The following command determines whether an "Current User, Current Host"
profile has been created on the local computer:
Test-Path -Path $PROFILE
------------------------------
For example, to create a profile for the
current user in the current PowerShell host application, use the following command:
if (!(Test-Path -Path $PROFILE)) {
New-Item -ItemType File -Path $PROFILE -Force
}
%USERPROFILE%\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
------------------------------
$HOME
$PROFILE
Test-Path -Path $PROFILE
$PROFILE | Select-Object *
------------------------------
------------------------------------------------------------
Open a new pane with splitPane
https://learn.microsoft.com/en-us/windows/terminal/tutorials/new-tab-same-directory#open-a-new-pane-with-splitpane
JSON
{ "command": { "action": "splitPane", "splitMode": "duplicate" } },
------------------------------------------------------------
https://learn.microsoft.com/en-us/windows/terminal/command-line-arguments
https://learn.microsoft.com/en-us/windows/terminal/command-line-arguments?tabs=windows
The wt command line accepts two types of values: options and commands.
wt [options] [command ; ]
------------------------------
Command line argument examples
https://learn.microsoft.com/en-us/windows/terminal/command-line-arguments?tabs=windows#command-line-argument-examples
------------------------------
### Windows Command Prompt:
wt new-tab PowerShell -c Start-Service ; new-tab cmd /k dir
wt -p "Command Prompt" ; split-pane -p "PowerShell"
wt -p "Command Prompt" -d %USERPROFILE%\Documents ; split-pane -p "PowerShell" -d %USERPROFILE%\Documents
wt ; new-tab cmd /k dir
wt -d %USERPROFILE%\Documents; new-tab -d %USERPROFILE%\Documents cmd /k dir
wt -d %USERPROFILE%\Documents; split-pane -d %USERPROFILE%\Documents cmd /k dir
NOTE:
wt -d %USERPROFILE%\Documents cmd /k dir ; split-pane -p "PowerShell" -d %USERPROFILE%\Documents
wt -d %USERPROFILE%\Documents ; split-pane -d %USERPROFILE%\Documents "wsl.exe"
------------------------------
### PowerShell
For example, to open Windows Terminal from PowerShell with three panes,
with the leftpane running a Command Prompt profile and the
right pane split between your PowerShell and
your default profile running WSL, enter:
wt -p "Command Prompt" `; split-pane -p "Windows PowerShell" `; split-pane -H wsl.exe
NOTE:
wt -p "Command Prompt" -d $HOME\Documents `; split-pane -p "PowerShell" -d $HOME\Documents
------------------------------------------------------------
{
"$help": "https://aka.ms/terminal-documentation",
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions":
[
{
"command": "find",
"keys": "ctrl+shift+f"
},
{
"command":
{
"action": "copy",
"singleLine": false
},
"keys": "ctrl+c"
},
{
"command": "paste",
"keys": "ctrl+shift+v"
},
{ "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" },
{ "command": "togglePaneZoom", "keys": "ctrl+f11" },
{ "command": { "action": "splitPane", "split": "vertical" }, "keys": "alt+shift+plus" },
{ "command": { "action": "splitPane", "split": "horizontal" }, "keys": "alt+shift+-" },
{ "command": {"action": "sendInput", "input": "cd ..\r"}, "keys": "ctrl+up" },
{ "_comment1": "Windows Command Prompt: cd %USERPROFILE%\\Documents\r" },
{ "command": {"action": "sendInput", "input": "cd $HOME\\Documents\r"}, "keys": "ctrl+1" },
{ "command": {"action": "sendInput", "input": "cd /mnt/c/Users/$USER/My\\ Documents\r"}, "keys": "ctrl+2" },
{ "command": {"action": "sendInput", "input": "cd %USERPROFILE%\\Documents\r"}, "keys": "ctrl+3" },
{
"name": "F- Change font size...",
"commands": [
{ "command": { "action": "adjustFontSize", "delta": 1 } },
{ "command": { "action": "adjustFontSize", "delta": -1 } },
{ "command": "resetFontSize" },
]
},
{
"name": "P- Pane ...",
"commands": [
{ "command": { "action": "splitPane", "split": "vertical" }, "keys": "alt+shift+plus" },
{ "command": { "action": "splitPane", "split": "horizontal" }, "keys": "alt+shift+-" },
{ "command": { "action": "moveFocus", "direction": "right" }, "keys": "alt+right" },
{ "command": { "action": "moveFocus", "direction": "left" }, "keys": "alt+left" },
{ "command": { "action": "swapPane", "direction": "right" } },
{ "command": { "action": "swapPane", "direction": "left" } },
{ "command": "toggleSplitOrientation" },
{ "command": { "action": "resizePane", "direction": "left" }, "keys": "alt+shift+left" },
{ "command": { "action": "resizePane", "direction": "right" }, "keys": "alt+shift+right" },
{ "command": "closePane", "keys": "ctrl+shift+w" },
{ "command": "togglePaneZoom", "keys": "ctrl+f11" },
{ "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" },
]
}
],
"copyFormatting": "none",
"copyOnSelect": false,
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"newTabMenu":
[
{
"type": "remainingProfiles"
}
],
"profiles":
{
"defaults": {},
"list":
[
{
"font":
{
"size": 14.0
},
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"hidden": false,
"name": "PowerShell",
"source": "Windows.Terminal.PowershellCore",
"startingDirectory": "%USERPROFILE%\\Documents",
"tabColor": "#012456",
},
{
"font":
{
"size": 14.0
},
"guid": "{51855cb2-8cce-5362-8f54-464b92b32386}",
"hidden": false,
"name": "Ubuntu",
"source": "CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc",
"startingDirectory": "%USERPROFILE%\\Documents"
},
{
"font":
{
"face": "SauceCodePro Nerd Font Mono",
"size": 14.0
},
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"hidden": false,
"name": "Command Prompt",
"startingDirectory": "%USERPROFILE%\\Documents"
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure",
"startingDirectory": "%USERPROFILE%\\Documents"
},
{
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"hidden": false,
"name": "Windows PowerShell"
}
]
},
"schemes":
[
{
"background": "#0C0C0C",
"black": "#0C0C0C",
"blue": "#0037DA",
"brightBlack": "#767676",
"brightBlue": "#3B78FF",
"brightCyan": "#61D6D6",
"brightGreen": "#16C60C",
"brightPurple": "#B4009E",
"brightRed": "#E74856",
"brightWhite": "#F2F2F2",
"brightYellow": "#F9F1A5",
"cursorColor": "#FFFFFF",
"cyan": "#3A96DD",
"foreground": "#CCCCCC",
"green": "#13A10E",
"name": "Campbell",
"purple": "#881798",
"red": "#C50F1F",
"selectionBackground": "#FFFFFF",
"white": "#CCCCCC",
"yellow": "#C19C00"
},
{
"background": "#012456",
"black": "#0C0C0C",
"blue": "#0037DA",
"brightBlack": "#767676",
"brightBlue": "#3B78FF",
"brightCyan": "#61D6D6",
"brightGreen": "#16C60C",
"brightPurple": "#B4009E",
"brightRed": "#E74856",
"brightWhite": "#F2F2F2",
"brightYellow": "#F9F1A5",
"cursorColor": "#FFFFFF",
"cyan": "#3A96DD",
"foreground": "#CCCCCC",
"green": "#13A10E",
"name": "Campbell Powershell",
"purple": "#881798",
"red": "#C50F1F",
"selectionBackground": "#FFFFFF",
"white": "#CCCCCC",
"yellow": "#C19C00"
},
{
"background": "#282C34",
"black": "#282C34",
"blue": "#61AFEF",
"brightBlack": "#5A6374",
"brightBlue": "#61AFEF",
"brightCyan": "#56B6C2",
"brightGreen": "#98C379",
"brightPurple": "#C678DD",
"brightRed": "#E06C75",
"brightWhite": "#DCDFE4",
"brightYellow": "#E5C07B",
"cursorColor": "#FFFFFF",
"cyan": "#56B6C2",
"foreground": "#DCDFE4",
"green": "#98C379",
"name": "One Half Dark",
"purple": "#C678DD",
"red": "#E06C75",
"selectionBackground": "#FFFFFF",
"white": "#DCDFE4",
"yellow": "#E5C07B"
},
{
"background": "#FAFAFA",
"black": "#383A42",
"blue": "#0184BC",
"brightBlack": "#4F525D",
"brightBlue": "#61AFEF",
"brightCyan": "#56B5C1",
"brightGreen": "#98C379",
"brightPurple": "#C577DD",
"brightRed": "#DF6C75",
"brightWhite": "#FFFFFF",
"brightYellow": "#E4C07A",
"cursorColor": "#4F525D",
"cyan": "#0997B3",
"foreground": "#383A42",
"green": "#50A14F",
"name": "One Half Light",
"purple": "#A626A4",
"red": "#E45649",
"selectionBackground": "#FFFFFF",
"white": "#FAFAFA",
"yellow": "#C18301"
},
{
"background": "#002B36",
"black": "#002B36",
"blue": "#268BD2",
"brightBlack": "#073642",
"brightBlue": "#839496",
"brightCyan": "#93A1A1",
"brightGreen": "#586E75",
"brightPurple": "#6C71C4",
"brightRed": "#CB4B16",
"brightWhite": "#FDF6E3",
"brightYellow": "#657B83",
"cursorColor": "#FFFFFF",
"cyan": "#2AA198",
"foreground": "#839496",
"green": "#859900",
"name": "Solarized Dark",
"purple": "#D33682",
"red": "#DC322F",
"selectionBackground": "#FFFFFF",
"white": "#EEE8D5",
"yellow": "#B58900"
},
{
"background": "#FDF6E3",
"black": "#002B36",
"blue": "#268BD2",
"brightBlack": "#073642",
"brightBlue": "#839496",
"brightCyan": "#93A1A1",
"brightGreen": "#586E75",
"brightPurple": "#6C71C4",
"brightRed": "#CB4B16",
"brightWhite": "#FDF6E3",
"brightYellow": "#657B83",
"cursorColor": "#002B36",
"cyan": "#2AA198",
"foreground": "#657B83",
"green": "#859900",
"name": "Solarized Light",
"purple": "#D33682",
"red": "#DC322F",
"selectionBackground": "#FFFFFF",
"white": "#EEE8D5",
"yellow": "#B58900"
},
{
"background": "#000000",
"black": "#000000",
"blue": "#3465A4",
"brightBlack": "#555753",
"brightBlue": "#729FCF",
"brightCyan": "#34E2E2",
"brightGreen": "#8AE234",
"brightPurple": "#AD7FA8",
"brightRed": "#EF2929",
"brightWhite": "#EEEEEC",
"brightYellow": "#FCE94F",
"cursorColor": "#FFFFFF",
"cyan": "#06989A",
"foreground": "#D3D7CF",
"green": "#4E9A06",
"name": "Tango Dark",
"purple": "#75507B",
"red": "#CC0000",
"selectionBackground": "#FFFFFF",
"white": "#D3D7CF",
"yellow": "#C4A000"
},
{
"background": "#FFFFFF",
"black": "#000000",
"blue": "#3465A4",
"brightBlack": "#555753",
"brightBlue": "#729FCF",
"brightCyan": "#34E2E2",
"brightGreen": "#8AE234",
"brightPurple": "#AD7FA8",
"brightRed": "#EF2929",
"brightWhite": "#EEEEEC",
"brightYellow": "#FCE94F",
"cursorColor": "#000000",
"cyan": "#06989A",
"foreground": "#555753",
"green": "#4E9A06",
"name": "Tango Light",
"purple": "#75507B",
"red": "#CC0000",
"selectionBackground": "#FFFFFF",
"white": "#D3D7CF",
"yellow": "#C4A000"
},
{
"background": "#300A24",
"black": "#171421",
"blue": "#0037DA",
"brightBlack": "#767676",
"brightBlue": "#08458F",
"brightCyan": "#2C9FB3",
"brightGreen": "#26A269",
"brightPurple": "#A347BA",
"brightRed": "#C01C28",
"brightWhite": "#F2F2F2",
"brightYellow": "#A2734C",
"cursorColor": "#FFFFFF",
"cyan": "#3A96DD",
"foreground": "#FFFFFF",
"green": "#26A269",
"name": "Ubuntu-ColorScheme",
"purple": "#881798",
"red": "#C21A23",
"selectionBackground": "#FFFFFF",
"white": "#CCCCCC",
"yellow": "#A2734C"
},
{
"background": "#000000",
"black": "#000000",
"blue": "#000080",
"brightBlack": "#808080",
"brightBlue": "#0000FF",
"brightCyan": "#00FFFF",
"brightGreen": "#00FF00",
"brightPurple": "#FF00FF",
"brightRed": "#FF0000",
"brightWhite": "#FFFFFF",
"brightYellow": "#FFFF00",
"cursorColor": "#FFFFFF",
"cyan": "#008080",
"foreground": "#C0C0C0",
"green": "#008000",
"name": "Vintage",
"purple": "#800080",
"red": "#800000",
"selectionBackground": "#FFFFFF",
"white": "#C0C0C0",
"yellow": "#808000"
}
],
"startOnUserLogin": false,
"tabSwitcherMode": "inOrder",
"theme": "dark",
"themes":
[
{
"name": "legacyDark",
"tab":
{
"background": null,
"showCloseButton": "always",
"unfocusedBackground": null
},
"window":
{
"applicationTheme": "dark",
"useMica": false
}
},
{
"name": "legacyLight",
"tab":
{
"background": null,
"showCloseButton": "always",
"unfocusedBackground": null
},
"window":
{
"applicationTheme": "light",
"useMica": false
}
},
{
"name": "legacySystem",
"tab":
{
"background": null,
"showCloseButton": "always",
"unfocusedBackground": null
},
"window":
{
"applicationTheme": "system",
"useMica": false
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment