Terminal Basics
Use the terminal to run development tools by typing commands. Codespaces, macOS, Linux, and WSL normally use a Bash-compatible shell. Native Windows development normally uses PowerShell.
Open VS Code's terminal with Terminal > New Terminal. It starts in the folder open in VS Code.
Navigation quick reference
| Goal | Bash and PowerShell |
|---|---|
| Show the current folder | pwd |
| List files | ls |
| Enter a folder | cd FOLDER_NAME |
| Go up one folder | cd .. |
| Refer to the current folder | . |
| Clear the terminal | clear in Bash; Clear-Host in PowerShell |
Put quotation marks around a path containing spaces:
cd "folder with spaces"
It is easier to avoid spaces when naming programming projects.
Useful terminal features
- Press Tab to complete a partially typed file or command.
- Press Up Arrow and Down Arrow to reuse earlier commands.
- Press
Ctrl+Cto interrupt a program that is running in the terminal. - Use
code .to open the current folder in VS Code when thecodecommand is available.
Platform differences
Bash runs a program in the current folder with ./program.exe. PowerShell uses
.\program.exe. Paths in Bash use /; native Windows paths normally use \ and a
drive letter such as C:.
Once you can navigate to a project folder, use Compile and Run to build a program. Use Input Redirection to send a file to a program.