7

I have a need to change the the default folder where Windows terminal is looking for settings.json file. From C:\Users%USER%\AppData\Local\Microsoft\Windows Terminal to my personal c:\tools\windowsterminal. The reason is because c:\tools is under version control and I'd like to keep it up to date to share between my several workstations.

How can I achieve this? As a workaround, maybe there is an option to start WindowsTerminal from cmd with specific parameter?

Please note, I know how to set starting directory for particular terminal, this is not what I want.

1
  • This feature has been discussed for a long time here (and also there). I'm hoping we could have a proper way in the future!
    – 4wk_
    Jan 4, 2023 at 14:49

5 Answers 5

6

You can use the mklink command in the Command Prompt.

You should use /H to make a so-called "hard link". Move the file first.

Something like this:

mklink /H "C:\Users\Sloven\AppData\Local\Microsoft\Windows Terminal\settings.json" "C:\tools\windowsterminal\settings.json"

Replace "Sloven" with the username you are using on your pc.

For more info see https://en.wikipedia.org/wiki/Symbolic_link#Microsoft_Windows or google "Symlink windows"

The command line arguments for Windows Terminal can be found here: https://docs.microsoft.com/en-us/windows/terminal/command-line-arguments?tabs=windows

0
5

Leaving it here to spare someone googling for Powershell solution

New-Item -ItemType HardLink -Path "C:\Users\Sloven\AppData\Local\Microsoft\Windows Terminal\settings.json" -Target "C:\tools\windowsterminal\settings.json"
2
  • What's the functional difference between doing it this way and making the mklink call?
    – Steven Lu
    Sep 22, 2022 at 2:39
  • 1
    Not sure there are any, but it is native powershell with all benifits that it provides if used in powershell. Sep 23, 2022 at 10:01
1

I have found using a symlink works for Windows Terminal. So this seems to be a preferred way since it makes it more obvious where the "official" file is.

The settings.json file always gets created if it's deleted if you have any Windows Terminal open. So it's tricky to run the mklink command. What I did on Windows 11 Preview was to right click C:/Windows/system32/cmd.exe and run it as admin, this lets you actually run the legacy cmd.exe (curiously just double clicking it fires up new Terminal) and you can run the mklink.

1

tl;dr

mklink /d on the directory LocalState did the trick!

1) Close Windows Terminal then move the entire folder LocalState from:

%LocalAppData%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState

to your desired location, for instance C:\backup\LocalState.


2) Right click on Command Prompt > Run as administrator, then:

mklink /d %LocalAppData%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState C:\backup\LocalState

3) Great success! Your settings are now at your desired location.

Output should be:

symbolic link created for C:\Users\xxx\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState <<===>> C:\backup\LocalState

Output in file explorer


background

As of 2023, a lot have changed since @Gatendo answer.

  • Windows Terminal settings.json file seems to be now located in C:\Users\xxx\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState (replace xxx with your username) instead of old location Local\Microsoft\Windows Terminal\settings.json
  • mklink /h didn't work out for me, settings were not saved properly between each run of Windows Terminal
  • however, creating a symbolic link with mklink /d for the entire LocalState folder worked pefectly!

See also:

0

An alternate (modern) option may be:

  • install of portable version of Windows Terminal
  • through Scoop package manager
  • as a result, configuration is located in $ScoopDir\persist\windows-terminal\settings\settings.json (with $ScoopDir defaults to ~/scoop/)
  • and it is possible to version control all apps creating a Git repository for persist folder

Benefits:

  • locate anywhere you want: run scoop installer specifying -ScoopDir
  • straight forward backup and restore process: just single folder copy
  • keep your applications up-to-date: with scoop update *
  • no need for Microsoft Store access: sometimes a corporate constraint
  • no need for administrative privileges: like with chocolatey alternative

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .