Opening Multiple Profiles on Startup
So, you have added all of the profiles you need for your Raspberry Pi's. When you start Windows Terminal, by default, it opens one profile and you can then open additional profiles from the pull-down menu which we saw in part 1.
You can improve this by automatically opening all required profiles when you start Windows Terminal. Before you do that we need to take a look at the JSON configuration file.
To open the JSON Configuration file go to settings and then select Open JSON File at the bottom of the page.
This will open the JSON file in your default editor for files with the extension json. If you don't have a default application you can choose notepad from the list.
Notepad++
At this point we will take you off on a tangent. There are better editors for editing JSON files and we would recommend you use Notepad++
This is a free and its use is governed by GNU General Public License. It has built in formatting and syntax checking. You can download it from the Microsoft Store or by clicking here.
From this point on we will be using this editor.
Backups are for Wimps
Well, actually they are not! Before you start editing the settings.json file we would recommend that you take a copy or backup of it. The file is located in the following path
C:\Users\<YOUR ACCOUNT>\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json
Replace <YOUR ACCOUNT> with the account you have logged in as. Make a copy either to a different file name like settings_backup.json or copy it to another folder.
Back to the main thread
So at this point we will assmune that you have your favourite editor setup and have a backup of the settings.json file.
Open the active settings.json file in your editor.
To open multiple profiles you need to add a "startupActions" line to the file. This needs to be a seperate string and we would recommend you add it to the bottom of the file which currently should look something like this.
"purple": "#800080", "red": "#800000", "selectionBackground": "#FFFFFF", "white": "#C0C0C0", "yellow": "#808000" } ] }
The syntax is crucial. The first thing you need to do is to add a coma after the last square bracket. This tell the program that there is another entry in the file to read. So the end of the file will now look like this.
"purple": "#800080", "red": "#800000", "selectionBackground": "#FFFFFF", "white": "#C0C0C0", "yellow": "#808000" } ], }
Next, we need to add the new string. This is in the format below.
"startupActions": "; new-tab -p raspberrypi --title raspberrypi"
You will need to change the profile name and title name, which are in bold above, to match your profile. So assuming our Raspberry Pi is called plex it would look like this.
"purple": "#800080", "red": "#800000", "selectionBackground":"#FFFFFF", "white": "#C0C0C0", "yellow": "#808000" } ], "startupActions": "; new-tab -p plex --title plex" }
Then save the file.
Problems and Solutions
Now if you had Windows Terminal open while you edited the file as you save it Windows Terminal will read in the new settings file. If you have made a typing error you will see a "Failed to reload settings" error message pop-up in the Windows Terminal. So as an example I have missed the coma after the square brackets. You would also see this pop-up when you open Windows Terminal if it was closed.
The error tells you what the problem is and which line and column it occurred in. This is another advantage of using notepad++ as it shows you the line numbers.
Finally! - Opening Multiple Profiles on Startup
So in the above example, we opened one additional profile on startup. What do we do if we want more profiles to open at startup? Simple we just add those to our StartupActions command.
So to open two profiles we make the following change to add a computer called pi-hole
"startupActions": "; new-tab -p plex --title plex; new-tab -p pi-hole --title pi-hole"
Each enter is separated by a semi-colon. So the end of the settings.json file will now look like this.
"purple": "#800080", "red": "#800000", "selectionBackground": "#FFFFFF", "white": "#C0C0C0", "yellow": "#808000" } ], "startupActions": "; new-tab -p plex --title plex; new-tab -p pi-hole --title pi-hole"
Remember you should create the profile first, if you don't the new tab will default to the Windows PowerShell profile.
Automagic Formatting
If you decided to add the new line at the top of the file rather than the bottom, Windows Terminal will automagically re-format the file for you when it reads it!! Our entry will be moved to the end of the file. If you are using notepad++ it will pop-up a message to say the file has changed and do you wish to re-read it. Click ok to re-read the file in.
That's it for now
I hope you are finding these posts useful and in the next one we will look at some more configuration.