VSCode Integrated Terminal
VS Code has a built-in integrated terminal. We can select the "Terminal" option in the menu bar and then choose "New Terminal":

You can also right-click a file in the directory and select 'Open in Integrated Terminal' from the dropdown menu:

Terminal shortcuts:
| Function | Windows/Linux | macOS |
|---|---|---|
| Show integrated terminal | Ctrl + ` | Ctrl + ` |
| New terminal | `Ctrl+Shift+``` | `Cmd+Shift+``` |
| Switch terminal | Ctrl+PageUp/PageDown |
Cmd+PageUp/PageDown |
| Close terminal | Ctrl+Shift+W |
Cmd+Shift+W |
Depending on the operating system, we can choose different terminal environments, such as PowerShell, Command Prompt, or Bash.

Enter the following command in the terminal to create a new file greetings.txt:
echo "Hello, VS Code" > greetings.txt
The default folder of the workspace is the root directory of the current project.
After creating the file, the 'Explorer' automatically displays the new file.

We can open multiple terminals at once. Click the 'Launch Profile' dropdown in the top-right corner of the terminal to view and select available terminal environments.

Run commands using the terminal
The terminal opens a default shell, such as Bash, PowerShell, or Zsh, and its working directory starts from the root of the workspace folder.

Enter basic commands like ls or dir to list the files in the current directory.
The terminal displays the command output directly:

Interacting with command output
The terminal in VS Code also provides interaction with command output. Commands often output file paths or URLs, and you may want to open or jump to these links directly.
For example, a compiler or linter may return an error message containing a file path and line number. You do not need to search for the file manually; simply select the link in the terminal output to open the file directly in the editor.
Let's see how to interact with command output in the terminal:
- Open the terminal where you previously ran
lsordira command. - In the terminal, hold down the
Ctrl/Cmdkey and hover over the file name, then select the link.

Note that when you hover over text in the output, it becomes a link.
When you select the file name, VS Code opens the selected file in the editor.
All text in the terminal output is clickable; if you select a hyperlink in the terminal, it opens in the default browser.
Create a Command.txt file containing available shell commands
In PowerShell:
Get-Command | Out-File -FilePath .\Command.txt
In Bash / Zsh:
ls -l /usr/bin > Command.txt
Enter the following command to search for commands in the Command.txt file:
In PowerShell:
Get-ChildItem *.txt | Select-String "dir"
In Bash / Zsh:
grep -n "dir" *.txt
Note that the command output will include the file name and the line number where the result was found, and the terminal recognizes this text as a link.
Select one of the links to open the file in the editor and jump to the specific line in the file.

Browse history commands
When using the terminal, we may need to view previous commands and their output, or we may want to re-run a command.
We can use a shortcut to quickly browse history commands: press the Ctrl + ↑ or ⌘ + ↑ shortcut to scroll up to the previous command in the terminal history.

If you press Ctrl + ↑multiple times, the terminal continues scrolling up through history. You can also use the Ctrl + ↓ shortcut to browse history downward.
Finally, a circular icon appears next to a previously run command; select that circular icon, then choose 'Rerun Command' to execute that command again.

Run commands in different shells
The terminal supports opening multiple terminals at the same time.
For example, we can use one terminal for Git commands and another for build scripts.
To add a new terminal in a different shell: select the down-arrow icon in the terminal panel to open the terminal dropdown menu, then choose an available shell.

**Note:** The available shells depend on the shells installed on your computer.
The new terminal opens with the shell you selected, and you can enter commands as before.

Tip: You can also select the + icon to create a new terminal for the default shell, using the shortcut ⌃⇧(Ctrl + Shift + `), or select from the menu bar Terminal > New Terminal to create a new terminal.
We can also drag the terminal from the terminal list into the editor area.
For example, we drag the terminal tab out of the VS Code window to make it a floating window.

**Move the terminal to the editor area:** When you hover over the terminal list, select the trash icon to close an open terminal.
