Terminal profiles lets you configure what shell you want
to run in your terminals and how they'll look in the
terminal group inside VS Code.
I've already got the settings.json file I was previously working
on open here in my editor.
I'll also open a new terminal and show you how we can get started
creating custom terminal profiles.
I'll click on the dropdown arrow in the top right corner
of the terminal panel.
From here, I'm going to click "Select Default Profile."
That brings up a list at the top with the profiles currently
available,
and I could now click on one of them to set it as my
default profile.
However, notice that they each have a little gear icon
to the right of them.
Clicking one of those will let me create a new profile based on
the one already in place, and will copy all of my profile
configurations to my settings.json file so I can make changes
to any of them.
One important thing to note is that terminal profiles are
platform-specific.
Different operating systems have different shells you can run.
So if you're on a Linux machine, for instance, the list you see
here will be different from this list on my Windows machine.
It can also vary just based on what shells you have installed.
I'll click the gear icon beside Ubuntu.
I'm running it with the Windows Subsystem for Linux, WSL.
I'm then prompted to provide a name for the profile.
I'll just accept the default suggestion.
That adds a big new section to the settings.json file with the
configuration information for each of my profiles.
The top-level setting added to my file appears here on Line 13,
terminal.integrated.profiles.windows.
If I were on a Linux machine, that last segment would be Linux,
and on a Mac, it would be OSX.
The value for that setting is a comma-separated list of
my current profiles, which each have their own
configuration properties.
Each profile basically configures VS Code to run a particular shell.
In most cases, that's done by providing a path property whose
value is a full path to the shell's executable.
You can see an example of that for my Ubuntu shell on Line 30.
On Windows machines, you can instead use
a source property, and Windows will attempt to detect
installations of PowerShell and Git Bash
as you see on Lines 15 and 27.
Also note the use of an environment variable on Lines 20
and 21 when specifying the path to the Windows command prompt.
There are lots of different variables available to help you
refer to different file paths and locations.
You can check out the VS Code website for a full list of those.
Let's now add a few properties to the Git Bash profile
so it looks like the one I configured earlier
in this chapter.
I'll add a comma after the source property,
and then press "Ctrl space" to bring up a code completion list of
the other available properties.
I'll add the override name property and set it to true
so that the title of this terminal is the title of the profile.
I'll also change the name of the profile to simply be git.
I'll now set the color property to red.
Lastly, I'll change the icon and assign it the git-branch-create
icon ID.
I could also add an args property like you see on the Ubuntu
profile below,
which would pass command line arguments to the shell executable,
but I don't really need that on this one.
If there are profiles in here that you don't want to appear as
choices in the new terminal dropdown, you can just assign them
the value null.
I'll do that for the command prompt profile.
The last settings change I want to make is to actually specify which
profile I want to be my default.
I'll do that with the terminal.integrated.defaultProfile.windows
property.
From the code completion list of possible values,
I'll select my newly configured git profile.
I'll now go to the terminal menu and open a new terminal and see
how these changes look.
That opens a new Git Bash shell with my new profile settings.
In the tabbed view on the right, you can see the label
I specified for it, along with the red Git
icon I selected.
Also note that if I click the dropdown to open a new terminal,
the Windows command prompt is no longer in the list since I set
it to null in my settings.
Terminal profiles are a way to customize how your terminal
shell start and look, as well as a way to configure
alternative shells you've installed,
so you can also use them inside VS Code. There are
one more way you can customize VS Code to fit the way
you want to work.
Coming up next, we'll take a look at task and how
you can use them to automate common operations.