-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Enable Terminal to persist / restore instance settings #766
Comments
IMO:
Open a fresh window. If you later add support for window history, they could use a "Recently closed windows" menu to restore the window with the same set of tabs.
That would be the simplest solution probably, but it might not be ideal if the application is improperly shut down. An alternative would be to continuously track open windows, tabs, panes, and working directories as changes are made, and persist those changes immediately (or on a timer).
Firefox and Chrome have an "Exit" option, which closes all windows. When you start the application again, the windows are restored. In general, I think that it would be great if Windows Terminal mimicked the behaviour of browsers. |
I know this is just about tabs and pane arrangements, but why not restore the buffer with all the previous output strings in place? |
I was thinking, if the state is stored in a human-readable format, it could also be hand-edited by users, and generated/modified by an external script or programme. A made-up example: {
"version": "0.2.0",
"state": {
"windows": [
{
"maximized": false,
"positionX": 500,
"positionY": 200,
"width": 1000,
"height": 2000,
"tabs": [
{
"title": "Project X",
"panes": [
{
"profile": "EF3E32A7-5FF6-42B4-B6E2-96CD7D033F00",
"directory": "C:/...",
// position/dimensions
}
]
}
]
}
]
}
} (As usual, I wish that people would move away from JSON and instead use something more suited to configuration files, like YAML.)
To limit the scope of the feature and get it released sooner. The format that I show above could easily be extended at a later stage. |
This comment has been minimized.
This comment has been minimized.
Use the browser behavior. It works and it is familiar. Also, would be nice to detach/reatach tabs (as Chrome).
It would be nice to persist everything (including history) of each tab. It would be amazing to have up arrow history persisted as well. You can use all my %USERPROFILE% space for that =)
As in a browser, when a tab is closed, its state remains (so I can reopen closed tabs with Ctrl+Shift+T). This would be awesome. Perhaps some settings to limit the number of persisted sessions?
As in a browser, [X] closes all tabs (I can reopen them with Ctrl+Shift+T - it will restore entire windows if needed). |
Updated title to better describe the ask, which also came-up in this Twitter thread: https://twitter.com/stanzillaz/status/1176675911275556866 |
Renaming it again because it really seems to pertain to saving info about specific instances of specific profiles. We can quibble about session/profile/instance later. 😄 |
I apologize if the naming is confusing. The issue, I think, is that a "session" is not well defined yet anywhere, and the wording was based on other applications (such as Edge) to be forward looking for when things like #961 are also implemented. The exact behavior of this feature when the setting is enabled is, from the docs (https://docs.microsoft.com/en-us/windows/terminal/customize-settings/startup#behavior-when-starting-a-new-terminal-session-preview)
|
Oh I see. That should be on by default to match every other Windows app then. Why is it an option like alrz said? :/ The actual restoring of content is completely separate to me. |
Currently the feature is being locked to the preview build while it is tested for stability (since there were a bunch of changes under the hood). While I cannot speak for them, I am sure the team will reevaluate whether it is a default or not depending on how it does. |
Yep, basically that. It's not on by default because we wanted to see how it landed. If it's stable enough, then it very well may end up as the default behavior in 1.12 stable. That being said, people FUCKING HATE defaults being changed on them, so no promises. |
[Insert XKCD] but i honestly expected that behaviour to not be behind both a preview release and an opt-in. |
Since you're already using 1.12 preview you can use this today. Open your settings (press You can also enable the feature by adding |
This works for me when launching Terminal regularly. However, when I launch it as an administrator, neither does it open the last session I had as a regular user, nor does it restore the last administrator session or even the window's position and size. |
@igorakkerman That's unfortunately by design for now. I've got a fix that's almost ready in #11222, but that didn't make the cut for 1.12 |
It need at least remember the current folder of each tab. |
@MrSparklle It'll do that, so long as you configure your shell to tell the Terminal about the current working directory, with |
@Rosefield using preview 1.12.2931.0 it doesn't seem that the state is properly saved. Tabs names and directories are lost. The only thing it is doing is opening the same number of tabs i had previously open at the default directory of C:\Users* |
Even this one not working for me, I tried and reopen terminal but is not working. |
@RehanHashmi did you write that json by hand? That doesn't look like the actual schema we ended up going with for the state file. Make sure to enable in
That's a known bug, #11878
You'll need to make sure to configure your shell to emit the CWD to the Terminal for us to be able to restore those |
@zadjii-msft Here is my settings.json file from windows shell, My requirement is like each time mostly I need to move to some directory and run few commands. Each time I open terminal I make few tabs and move each tab in different directory to run those commands, I want it like when I open windows shell, It automatically open 4 tabs in different file location, Please guide me what Should I do, I tried to use "state" but I guess I applied wrongly or did something wrong. it is not working, {
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions": [
{
"command": "unbound",
"keys": "ctrl+shift+t"
},
{
"command": "unbound",
"keys": "ctrl+shift+w"
},
{
"command": "unbound",
"keys": "alt+f4"
},
{
"command": {
"action": "copy",
"singleLine": false
},
"keys": "ctrl+c"
},
{
"command": {
"action": "newTab"
},
"keys": "ctrl+t"
},
{
"command": "paste",
"keys": "ctrl+v"
},
{
"command": "closeWindow"
},
{
"command": "find",
"keys": "ctrl+shift+f"
},
{
"command": {
"action": "splitPane",
"split": "auto",
"splitMode": "duplicate"
},
"keys": "alt+shift+d"
},
{
"command": "closePane",
"keys": "ctrl+w"
}
],
"copyFormatting": "none",
"copyOnSelect": false,
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"launchMode": "default",
"profiles": {
"defaults": {
"backgroundImage": null,
"backgroundImageStretchMode": "uniform",
"colorScheme": "Solarized Dark",
"cursorShape": "vintage",
"font": {
"face": "Cascadia Code",
"size": 10,
"weight": "bold"
},
"icon": "C:\\Users\\Azam\\Pictures\\Camera Roll\\extra\\0fMGlH3.jpg",
"padding": "9",
"tabTitle": "Welcome Rehan"
},
"list": [
{
"commandline": "powershell.exe",
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"hidden": false,
"name": "Windows PowerShell",
"colorScheme": "Campbell",
"cursorColor": "#C19C00",
"cursorShape": "filledBox",
"fontSize": 9,
"padding": "5, 5, 5, 5"
},
{
"commandline": "cmd.exe",
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"hidden": false,
"name": "Command Prompt"
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
},
{
"guid": "{2ece5bfe-50ed-5f3a-ab87-5cd4baafed2b}",
"hidden": false,
"name": "Git Bash",
"source": "Git"
}
]
},
"schemes": [
{
"background": "#0C0C0C",
"black": "#000000",
"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"
}
],
"theme": "system",
"state": {
"windows": [
{
"maximized": false,
"positionX": 500,
"positionY": 200,
"width": 1000,
"height": 2000,
"tabs": [
{
"title": "Project X",
"panes": [
{
"profile": "61c54bbd-c2c6-5271-96e7-009a87ff44bf",
"directory": "C:/Data/Tools/"
}
]
}
]
}
]
}
} |
Otherwise, what I used to do before that feature landed, was add an action like the following: (copypasta from a while back) { "command": { "action": "wt", "commandline": "new-tab --title OpenConsole cmd.exe /k #work 15 ; split-pane -s .30 --title OpenConsole cmd.exe /k #work 15 ; split-pane -s .25 -H cmd.exe /k media ; new-tab --title \"Symbols Script\" powershell dev\\symbols.ps1 ; new-tab -p \"Ubuntu 18.04\" ; new-tab -p \"microsoft/Terminal\" ; sp -V -p \"microsoft/Terminal\" ; sp -H -p \"microsoft/Terminal\" ; focus-tab -t 0" }, "name": "Good Morning" }, (you could probably make it shorter by replacing I add that to the You could repeat this for multiple different "session"s if you wanted. That way you could have layouts pre-defined for various different dev environments. |
I'm using Terminal 1.14.2281.0 and would really like the window position to stay persistent but it doesn't. I have a |
This comment was marked as off-topic.
This comment was marked as off-topic.
Necro'ing an old thread is not typically the best place for bug reports 😉 However, we definitely do intentionally treat @Poopooracoocoo your issue is already tracked in #12633, no need to pollute discussion here. |
Well, without preserving the last opened path in each tab it seems pretty useless. |
Sorry for disturbing you in such a manner, but it's been a year and it seems like you have some idea of what's going on with the roadmap. Could you please shed some light on the implementing saving session feature plans? By saving session I mean the Terminal's ability when launched to reopen tabs with their names, positions and (missed now) the opened paths. Currently I have lets say three projects. I open three PowerShell tabs for these projects and navigate to corresponding path for each of them. But when I reopen Terminal, each tab's path is reset to a user's home directory, which seems like not expecting behavior. |
You know, that's actually in the docs: Tutorial: Opening a tab or pane in the same directory in Windows Terminal. You need to set up your shell for it to cooperate with the Terminal - that doesn't work magically on Windows, unfortunately. @Kolobamanacas This feature was implemented like, a year ago. Did you enable the following setting: Or do you want a more generic "I want to save this set of tabs as a session, but not necessarily reopen the Terminal with that session every time"? In which case, you might be interested in #11526 |
zadjii-msft, thanks a lot for your reply. The funny thing is that while answering simontom's question, you have accidentally answered mine. I personally think that most users agree, that "restore session" feature means that when one launches the application, one continues exactly where one left. Who could possibly know (
My expectations:
Current behavior is all tabs are opened in the user's home directory. Thanks to your post and the link you've provided I'm now aware that I need to set up my shell for it to cooperate with the Terminal by appending the following line to the prompt (at least for PowerShell profiles) for it to work as I expect.
So my problem is solved. The only thing I wish to mention is that if ordinary user doesn't spend some time on intense research he would be completely unaware of the existence of such a setting. So maybe some kind of hint within the GUI could help, stating for a shell need to be set up accordingly in order to |
Well, yes :) |
I tried setting it like that, but it only restores the previous number of sessions (number of tabs). But the command content of each tab is completely gone. |
@ngocbae98 This is the wrong issue. What you want is #961. |
Let the user set a global setting to have the terminal re-open with whatever profiles were last open.
Thoughts:
THIS IS NOT A DISCUSSION OF PRESERVING WINDOW CONTENT, ONLY OPEN WINDOW PROFILES
This also includes restoring things like previous window positions.
The text was updated successfully, but these errors were encountered: