Windows Terminal, how to save split pane layout? - terminal

Is there a way I can save current split panel layout and profile for each panel so I don't need to split and open profile one by one again?

This feature does not yet exist as part of Windows Terminal.
However, this feature was suggested, and the suggestion has been accepted and is being tracked in the Windows Terminal github issues backlog:
https://github.com/microsoft/terminal/issues/3759
Work-around:
You can call windows terminal (wt) from the command line and specify starting directories, splits, tabs, profiles, etc.
For example, run this from command line and it will open up 2 Windows Terminal tabs, the first tab will be a split layout with PowerShell profile + your default profile, and the other tab will use the Ubuntu WSL profile:
wt -d "C:\Windows\System32" -p "PowerShell"; sp -V -d "%USERPROFILE%"; nt -p "Ubuntu" --title "wsl" --tabColor "#FF0000"
Better yet, set this command as the file location for a shortcut on your desktop and you can just double click the shortcut to open your favorite Windows Terminal configuration.
See more wt command line options here:
https://learn.microsoft.com/en-us/windows/terminal/command-line-arguments?tabs=windows

Related

Open a new tab in the running instance of Windows Terminal from CLI

Is there a way to open a new tab in a running instance of Windows Terminal from CLI and make it point to a specific folder?
Every time I run wt.exe -d c:\my-folder it opens a new window.
Now, we have this option in Windows Terminal's Settings.
If someone needs the commands to create a new tab (and not open a new window) from a context menu item:
(if you are already in the directory):
wt -w 0 nt
(and if you click on the directory):
wt -w 0 nt -d %1
(to open in the current directory):
wt -w 0 nt -d %CD%
You can add these commands in the respective registry of each item (or in a new one)
Source: the GitHub discussion in the other answer.
if you run that in cmd or a script, it launches a new instance if none already running, or adds a tab if there is a running instance.
This is an outstanding issue that is going to get fixed eventually: Add support for wt.exe to run commands in an existing Terminal Window #4472
No, as per the documentation, calling wt.exe
...will always open a new window. Windows Terminal is not yet capable of opening new tabs or panes in an existing instance.

How to split the Git Bash into more than one “view” in Windows?

I want to run two commands at the same time in Git Bash.
webpack -w
node server.js
So i want to split my terminal into two or multiple tabs.
How to split the terminal into multiple views ?
Your requirements are:
Use git bash
Split into 2 or more tabs
You can archive this the following way.
Download Visual Studio Code
Change your integrated terminal to git bash.
"terminal.integrated.shell.windows": "C:\Program Files\Git\bin\bash.exe"
Open a new terminal by clicking on Terminal > new Terminal in VS Code top navigation bar.
Split your terminal
Git Bash, won't allow users to split the screen in to two as the features don't exist. The only way is to use alternative or use ConEmu to configure, my personal preference would be Cmder (console emulator) and other options would be Moba Xterm. Cmder is open source and completely free. This would be much easier than configuring ConEmu.
Cmder: http://cmder.net/
MobaXterm: https://mobaxterm.mobatek.net/
To duplicate a GIT bash in windows press Alt + F2.
This opens a new terminal in the same path as the previous.
You can achieve this in Windows Terminal:
https://learn.microsoft.com/en-us/windows/terminal
Windows Terminal Preview can be configured to save your panes layout on close:
https://www.microsoft.com/en-au/p/windows-terminal-preview/9n8g5rfz9xk3
See this post for how to add a Git Bash profile automatically:
https://stackoverflow.com/a/69093260
Other features include:
Set starting directory for Git Bash profile and Defaults
Customise pane theme, colors, fonts, background images (including animated gifs), transparency, cursor shape, 'retro terminal effects' etc
Launch two instances of GIT Bash and press win + → to automatically divide the screen into two halves and select desired programs.

How can I launch command-line python 2.7 programs into full screen by default on Windows?

I want to launch my python programs into full screen or whenever i run it from cmd or powershell i always want to get the output into full screen. How can I do that ?
Create a shortcut for .cmd file and modify the Shortcut tab under Properties. Choose "Maximized" from Run: section.

Terminal window with running command

Is it possible to start a new window of terminal as in Windows: start example.bat? It opens a new window and runs an command.
You can do this using the open command, or ossascript. Here are some related questions using those commands in their answers:
Programmatically launch Terminal.app with a specified command (and custom colors)
Running a command in a new Mac OS X Terminal window
What arguments does the Mac's Terminal.app accept?
The open command is more straightforward, allowing you to specify the name of a script or command to be run, as noted in one answer. That describes this case (referring to open(1)):
open -a Terminal.app file
where file is the application to be opened. You may have to give its full pathname. The manual describes also a --args option which it states can be used to pass parameters to the application.

Run a Command Prompt command from Desktop Shortcut

Is it possible to create a desktop shortcut that, when pressed, will open command prompt and run a pre-defined command?
Create A Shortcut That Opens The Command Prompt & Runs A Command:
Yes! You can create a shortcut to cmd.exe with a command specified after it. Alternatively you could create a batch script, if your goal is just to have a clickable way to run commands.
Steps:
Right click on some empty space in Explorer, and in the context menu go to "New/Shortcut".
When prompted to enter a location put either:
"C:\Windows\System32\cmd.exe /k your-command" This will run the command and keep (/k) the command prompt open after.
or
"C:\Windows\System32\cmd.exe /c your-command" This will run the command and the close (/c) the command prompt.
Notes:
Tested, and working on Windows 8 - Core X86-64 September 12 2014
If you want to have more than one command, place an "&" symbol in between them. For example: "C:\Windows\System32\cmd.exe /k command1 & command2".
Yes, make the shortcut's path
%comspec% /k <command>
where
%comspec% is the environment variable for cmd.exe's full path, equivalent to C:\Windows\System32\cmd.exe on most (if not all) Windows installs
/k keeps the window open after the command has run, this may be replaced with /c if you want the window to close once the command is finished running
<command> is the command you wish to run
The solutions turned out to be very simple.
Open text edit
Write the command, save as .bat.
Double click the file created and the command automatically starts running in command-prompt.
Create new text file on desktop;
Enter desired commands in text file;
Rename extension of text file from ".txt" --> ".bat"
Yes. One option you have is to create a batch file containing the command
cmd -c {your command}
or
cmd -k {your command}
The shortcut will then be to this batch file.
This is an old post but I have issues with coming across posts that have some incorrect information/syntax...
If you wanted to do this with a shorcut icon you could just create a shortcut on your desktop for the cmd.exe application. Then append a /K {your command} to the shorcut path.
So a default shorcut target path may look like "%windir%\system32\cmd.exe", just change it to %windir%\system32\cmd.exe /k {commands}
example: %windir%\system32\cmd.exe /k powercfg -lastwake
In this case i would use /k (keep open) to display results.
Arlen was right about the /k (keep open) and /c (close)
You can open a command prompt and type "cmd /?" to see your options.
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true
A batch file is kind of overkill for a single command prompt command...
Hope this helps someone else
I tried this, all it did was open a cmd prompt with "cmd -c (my command)"
and didn't actually run it. see below.
C:\windows\System32>cmd -c (powercfg /lastwake)
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\windows\System32>
***Update
I changed my .bat file to read "cmd /k (powercfg /lastwake)" and it worked.
You can also leave out the () and it works too.
You can also create a shortcut on desktop that can run a specific command or even a batch file by just typing the command in "Type the Location of Item" bar in create shortcut wizard
Right click on Desktop.
Enter the command in "Type the Location of Item" bar.
Double click the shortcut to run the command.
Found detailed Instructions here
Using the Drag and Drop method
From the windows search bar type in cmd to pull up the windows bar operation.
When the command line option is shown, right click it and select Open File Location.
The file explorer opens and the shortcut link is highlighted in the folder. If it is not highlighted, then select it.
Hold down the Control key and using the mouse drag the shortcut to the desktop. If you don't see Copy to Desktop while dragging and before dropping, then push down and hold the Control key until you see the message.
Drop the link on the desktop.
Change properties as needed.

Resources