The terminal is one of the most commonly used tools for many
software developers, probably second only
to their editors.
Therefore, it makes sense that the Visual Studio Code team decided to
build a terminal right into the application.
This cuts down on application switching,
and the tight integration provides some nice benefits you won't get
when working with an external terminal.
As you might expect, there are quite a few ways to open
the terminal in VS Code.
Probably, the most obvious is to go to the terminal menu and
select "New Terminal."
Another option is to go to the View menu and select "Terminal."
I personally find myself primarily using the keyboard shortcut
associated with this command.
It's Ctrl backtick, which will toggle the terminal
in and out of view.
I'll just click on this menu option now since I already
have the menu open.
By default, the terminal opens in its own panel at the bottom
of the screen.
I'm on a Windows machine, and by default, that runs PowerShell
inside new terminals.
You can see an indication that it's PowerShell in the upper right
corner of the terminal
along with a few other helpful dropdowns and buttons.
I can now do anything I might choose to do in an external
PowerShell window.
I can review some files, run commands,
and do anything else PowerShell is capable of doing.
Notice that by default, the terminal opened in the root
directory of my project.
I keep saying "by default" because just about everything about the
terminal is configurable.
We'll explore some of its many options coming up,
but let's first look at a few more ways you can open and use it.
You can open additional terminals by clicking the plus button
in the upper right corner.
You can open another terminal, but with a different shell by
clicking the little down arrow button.
You can see some of the other shells available on my machine
based on what I have installed.
Your list may be a little different.
I'll open a Git Bash terminal.
Once you have two terminals open, they'll both appear in a tabbed
view on the right.
You can simply click on them to move between them.
You can also make a few quick customizations to the tabbed list
so it's easy to identify the terminal you want for
a specific task.
For instance, if I'm planning to use this Bash terminal for command
line Git operations, I could right-click on
it and choose "Rename"
to give it a more meaningful name. I'll rename it to git.
I'll also right-click and select "Change Icon" and pick a Git
icon from the pop up list.
Just to make it stand out a little more,
I'll also change its color to red.
Selecting a terminal in the list brings up a trash can icon next
to it, you can use to close it, as well as a split button that
will open another terminal next to it in the same terminal group.
I'll click that.
A new PowerShell terminal opens next to my Git Bash terminal.
If you don't like your new terminal appearing in the
panel at the bottom
and you'd rather just have it in the editor area with
your code files,
that's also an option.
I'll right-click on my original PowerShell terminal and then
select "Move Terminal into Editor Area."
Now, it's just another tab in my editor area,
and even if I press "Ctrl backtick" to close the terminal
group at the bottom,
this one stays open among any code files I might also be working on.
I've already shown you several different ways to open
a new terminal, but I want to show you one more
you might also find helpful
before we move on to some useful customizations.
If you need to run a shell command inside a nested directory
in your project, you can quickly open a terminal in
that directory from the project explorer.
For instance, in my project explorer,
I'll first expand the _css directory.
Inside there, is another directory named images.
I can open a new terminal in that directory by right-clicking on it
and choosing "Open in Integrated Terminal."
You can see from my prompt and the output of the PWD command that I'm
in the CSS images directory inside the root of my project.
Okay. You now have lots of options for opening and arranging
terminals and using different shells with them.
Up next, I'll introduce you to just a few of the seemingly
endless number of ways you can customize your terminals
in VS Code.