Cursor Terminal
Cursor is built on Visual Studio Code, retaining VS Code's powerful features and familiar operating experience, while adding AI-assisted programming capabilities.
Cursor has a built-in integrated terminal, which operates the same as VS Code's integrated terminal. We can select the "Terminal" option from the menu bar and then choose "New Terminal":
!(#)
You can also select a file in the directory, right-click, and choose "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" will automatically display the new file.
!(#)
We can open multiple terminals at the same time. Click the "Launch Profile" dropdown menu in the upper right corner of the terminal to view available terminal environments and make a selection.
!(#)
* * *
## Running Commands Using the Terminal
The terminal opens a default shell, such as Bash, PowerShell, or Zsh. The working directory of the terminal starts from the root directory of the workspace folder.
!(#)
Enter basic commands like ls or dir to list files in the current directory.
The terminal will directly display the command output:
!(#)
### Interacting with Command Output
The terminal in VS Code also provides the ability to interact 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 code linting tool might return an error message containing a file path and line number. You don't need to manually search for the file. 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:
1. Open the terminal where you previously ran the `ls` or `dir` command.
2. In the terminal, hold the `Ctrl/Cmd` key, hover your mouse over the filename, and select the link.
!(#)
Note that when you hover your mouse over text in the output, it will turn into a link
YouTip