Skip to content

Consider adding a WT_PROFILE env var pointing to settings file #4566

Open

Description

@oising

If the settings UI is not planned until after 1.0, then I strongly recommend adding an environment variable with the path to the json settings file, so it can be edited with the editor of choice (vi, notepad, nano, emacs, whatever) from within the shell of choice without burning brain calories trying to find it buried in AppData. Also: Relying on the GUI menu is, well, unreliable, due to there being no guarantee of a valid file association for json files.

We've already got WT_SESSION env var -- something like WT_PROFILE would be useful.

Then from within cmd or powershell, I can easily edit settings with my preferred editor, or interactively using $settings = gc $env:WT_PROFILE | convertto-json and flipping settings on the object model directly before saving it back out.

Activity

  1. added
    Issue-Feature
    on Feb 13, 2020
  2. ghost added
    Needs-Triage
    on Feb 13, 2020
  3. ghost added
    Needs-Tag-Fix
    on Feb 13, 2020
  4. added
    Area-Settings
    Help Wanted
    Product-Terminal
    on Feb 13, 2020
  5. ghost removed
    Needs-Tag-Fix
    on Feb 13, 2020
  6. akulbe commented on Feb 13, 2020

    @akulbe

    Oisin Grehan (@oising) Are you able to access settings at all? I no longer find a profiles.json file, and Ctrl-, no longer even pulls one up.

  7. oising commented on Feb 13, 2020

    @oising
    CollaboratorAuthor

    Aaron Kulbe (@akulbe) I think now there is only a defaults.json and you may create your own profiles.json file as a differential to this (things in your file will override the defaults).

    There's a readonly defaults.json alongside the executable, and a user-editable one for overrides in your local app data folder.

    Run the following one-liner in powershell to open the defaults.json file:

    notepad (join-path ((dir (gcm wt.exe).source).target | split-path) defaults.json)

    The profiles.json file is in %LOCALAPPDATA%\packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\

  8. JustinGrote commented on Feb 14, 2020

    @JustinGrote

    Conflicts with #3589 request, maybe have the variable be WT_CONFIGFILE?

    Currently the location is pretty stable and discoverable, this change would only be relevant if you could also customize the path.

  9. Jaykul commented on Feb 20, 2020

    @Jaykul
    Contributor

    Does anyone actually have a use for WT_Session? Is it just so you can distinguish different terminal connections to the same (e.g. ssh) session? To me, the WT_Profile in #3589 would be really useful. This one, pointing to the config file (confusingly named profile.json), would also be useful but it feels less useful -- isn't there only one location (plus one for dev builds)?

  10. oising commented on Feb 20, 2020

    @oising
    CollaboratorAuthor

    Conflicts with #3589 request, maybe have the variable be WT_CONFIGFILE?

    Currently the location is pretty stable and discoverable, this change would only be relevant if you could also customize the path.

    Well there are actually two config files, in different locations - I propose:

    env var WT_PROFILES (user editable) for:

    %LOCALAPPDATA%\packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\profiles.json

    env var WT_DEFAULTS (read only, for reference) for:

    %PROGRAMFILES%\WindowsApps\Microsoft.WindowsTerminal_0.9.433.0_x64__8wekyb3d8bbwe\defaults.json

    While they are "discoverable" - for certain definitions of discoverability - I think they are unwieldy enough to benefit from an environment variable.

    Joel Bennett (@Jaykul) I really like your idea for the active profile ID. What do you suggest for a name? I think WT_PROFILE is too close to WT_PROFILES (which matches the name of the json file, likewise for WT_DEFAULTS)

  11. removed
    Needs-Triage
    on Feb 22, 2020
  12. chwarr commented on Mar 8, 2020

    @chwarr
    Member

    On February 20, 2020, Oisin Grehan (@oising) said:

    env var WT_DEFAULTS (read only, for reference)

    Can you expand on what you mean by a read-only environment variable? Windows, doesn't have anything like read-only environment variables AFAIK. A process is free to modify its own environment or to start children with custom environments.

    My expectation of a variable like WT_PROFILE would be that I could use it to change where Windows Terminal reads user settings from. I would use it to move this to my "dotfiles" repository where I keep various application settings so I can version and sync them across machines.

    Based on how other, similar software works, I think it would make sense if Windows Terminal only read this environment variable at process start up and then monitored the path for changes. It would also be reasonable for Windows Terminal to detect changes to the environment "template" by handling WM_SETTINGCHANGE notifications. (Though, there are some subtle details to consider about when changes are applied. Lots of thoughts in #1125, "Feature Request: Terminal should listen for the WM_SETTINGCHANGE for environment variable updates".)

  13. 10 remaining items

  14. changed the title [-]Consider adding a WT_PROFILE env var pointing to settings file for 1.0 release[/-] [+]Consider adding a WT_PROFILE env var pointing to settings file[/+] on Jun 26, 2020
  15. sassdawe commented on Aug 28, 2020

    @sassdawe

    Just to complicate things a little bit.

    What about WT_SettingsPath which could give back the path of the same file which gets opened by hitting ctrl+, ?

    The path in the name would really limit the scope, and make most of the questions irrelevant. I realize that this is not the end solution but sounds like a great MVP.

    If you only give back the currently used, and editable path, it will be up to the users to decide what do they want to do with it. This approach sounds supportable in the future, because if you change the path - to support roaming or whatever - or the file name, etc., WT must always know where the active settings are, because it had to read the content.


    I'm editing the content of the settings.json in PSWinTerminal but figuring out if the running terminal is the GA version or it Preview isn't pretty. I'd to look for the parent process' path and look for the word preview in the folder name. With PowerShell this is easy, but with Windows PowerShell I had to use Get-CimInstance.

    It would be really nice if I can simply just use WT_SettingsPath to get the path of the settings file.


    What do you think?

  16. zadjii-msft commented on Sep 29, 2020

    @zadjii-msft
    Member

    From arqtiq in #7773

    Numerous times I tried to automate some settings / profiles edits on the Terminal settings themselves, and I usually lack informations about the current tab environment :

    • What is the current loaded profile / scheme ?

    • Is the host the preview package ?

    I'm sure there are also more info we could export to env vars based on people needs.
    This would be veery useful to manage the terminal settings / themes / profiles directly from the command line !

    When opening a new tab, set:

    • $WT_CURRENT_PROFILE (Microsoft PowerShell, CMD, ...)

    • $WT_CURRENT_SCHEME

    • $WT_IS_PREVIEW (1 / 0, if the current terminal running package is the preview one)

  17. bradrice commented on Mar 19, 2021

    @bradrice

    How do you find the editable defaults.json file if I run notepad (join-path ((dir (gcm wt.exe).source).target | split-path) defaults.json)
    it pulls up the one that I can't edit. If I hit Alt-Settings, it opens a defaults.json file, but I can't save it.

  18. zadjii-msft commented on Mar 19, 2021

    @zadjii-msft
    Member

    Brad Rice (@bradrice) Yep, that's correct. You shouldn't be editing defaults.json. That file technically isn't even read by the Terminal - it's more of a reference of what the Terminal's hard-coded defaults are.

  19. bradrice commented on Mar 19, 2021

    @bradrice

    The problem I have with Powershell and Windows Terminal is using a theme for vim. I would love to ise gruvbox. For some reason my vim has these red backgrounds with red type and I can't read it, when I'm using code completion that is flagging me of an error in my typescript. Is there a way to make a powershell terminal behave more like a linix or mac terminal with regard to respecting a vim colorscheme?

  20. zadjii-msft commented on Mar 19, 2021

    @zadjii-msft
    Member

    You might be better off filing a new issue rather than bumping this old one. Probably best to include if you're using vim.exe or WSL vim, maybe a link to the vim scheme you're trying to use, and include your settings.json

  21. sassdawe commented on Mar 19, 2021

    @sassdawe

    it pulls up the one that I can't edit. If I hit Alt-Settings, it opens a defaults.json file, but I can't save it.

    Brad Rice (@bradrice) you don't need the ALT button, a pure click on the Settings will open the setting.json, which is editable.

  22. bradrice commented on Mar 19, 2021

    @bradrice

    You're right Mike Griese (@zadjii-msft) , I should keep issues separate. Thanks David Sass (@sassdawe) that helped. I didn't see the link to the json file when I hit settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-SettingsHelp WantedIssue-FeatureProduct-Terminal

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions