Как открыть терминал intellij idea
Command-line interface
Use IntelliJ IDEA features from the command line: open files and projects, view diffs, merge files, apply code style formatting, and inspect the source code.
For information about running command-line tools from inside IntelliJ IDEA, see Terminal.
Launcher for a standalone instance
This command changes the PATH environment variable for the current shell only (the current instance of cmd.exe ). If you want to update it permanently for the current user, run setx :
The installer can do this for you if you select Add launchers dir to the PATH on the Installation Options step of the setup wizard.
To run IntelliJ IDEA from the shell, use the open command with the following options:
-a : specify the application.
—args : specify additional arguments when passing more than just the file or directory to open.
-n : open a new instance of the application even if one is already running.
For example, you can run IntelliJ IDEA.app with the following command:
If IntelliJ IDEA is not in the default /Applications directory, specify the full path to it.
You can create a shell script with this command in a directory from your PATH environment variable. For example, create the file /usr/local/bin/idea with the following contents:
Make sure you have permissions to execute the script and since /usr/local/bin should be in the PATH environment variable by default, you should be able to run idea from anywhere in the shell.
Since /usr/local/bin should be in the PATH environment variable by default, you should be able to run the idea command from anywhere in the shell.
Shell scripts generated by the Toolbox App
If you are using the Toolbox App to install and manage JetBrains products, it can create shell scripts for launching your IDEs from the command line.
Generate shell scripts
If necessary, change the shell scripts location.
If you have several versions of the same IDE, the Toolbox App generates a shell script for each version with a unique name. You can change the name of the shell script for an IDE instance in the settings for this specific instance.
Change the name of the shell script
Open the Toolbox App.
At the bottom, change the Shell script name field.
By default, the Toolbox App puts shell scripts in a directory from the system PATH environment variable, so you can run the name of the script as a command to launch IntelliJ IDEA from any working directory.
Command-line arguments
The launcher script accepts commands, options, and other arguments to modify its behavior:
Launch IntelliJ IDEA.
Path to file or directory
Open the file or directory specified as the argument.
Open the diff viewer to see differences between two specified files.
Open the Merge dialog to merge the specified files.
Apply code style formatting to the specified files.
Perform code inspection on the specified project.
Do not show the splash screen when loading IntelliJ IDEA.
Do not reopen projects and show the welcome screen. This can help if a project that was open crashes IntelliJ IDEA for some reason.
Do not load manually installed plugins. This can help if a plugin that you installed crashes IntelliJ IDEA for some reason. You will be able to start the IDE and either disable or uninstall the problematic plugin.
Wait for the files to be closed before returning to the command prompt.
Как / могу ли я отобразить окно консоли в Intellij IDEA?
возможно ли иметь консольное окно / интерфейс командной строки как часть интерфейса Intellij IDEA? Я бы предпочел перейти в командную строку для определенных действий, таких как работа с GIT или запуск процессов сборки, но на данный момент это означает, что отдельное окно консоли открыто и alt-tabbing.
есть ли какая-то интегрированная консоль? И даже лучше, может ли он автоматически указывать на мой корень проекта по умолчанию?
8 ответов
обновление: функция консоли / терминала была реализована в IDEA 13, PyCharm 3, RubyMine 6, WebStorm / PhpStorm 7.
есть запрос связанных функций, пожалуйста, голосуйте. Настройка внешний инструмент запустить терминал можно использовать в качестве обходного пути.
IntelliJ IDEA 14 & 15 & 2017:
Вид > Окна Инструментов > Терминал
больше IntelliJ 13+ ярлыки для терминала
Mac OS X:
⌘cmd в ⇧Shift и A введите нажмите Enter
⇧Shift и ⇧Shift и ⇧Shift и ⇧Shift и введите нажмите Enter
Windows:
alt F12 пресс Enter
ctrl ⇧Shift и A начните вводить нажмите Enter
⇧Shift и ⇧Shift и введите нажмите Enter
в IntelliJ IDEA 2016.1.1:
Он покажет вам консоль
наведите курсор на боковую панель и выберите «Восстановить визуальные элементы отладчика. «
Я использую Shift + F12 чтобы снова показать консоль (или
Terminal
IntelliJ IDEA includes an embedded terminal emulator for working with your command-line shell from inside the IDE. Use it to run Java tools, Git commands, set file permissions, and perform other command-line tasks without switching to a dedicated terminal application.
Open the Terminal tool window
By default, the terminal emulator runs with the current directory set to the root directory of the current project. For information about changing the default start directory, see Configure the terminal emulator.
Alternatively, you can right-click any file (for example, in the Project tool window or any open tab) and select Open in Terminal from the context menu to open the Terminal tool window with a new session in the directory of that file.
Start a new session
To run multiple sessions inside a tab, right-click the tab and select Split Right or Split Down in the context menu.
The Terminal saves tabs and sessions when you close the project or IntelliJ IDEA. It preserves tab names, the current working directory, and even the shell history.
Press Alt+Right and Alt+Left to switch between active tabs. Alternatively, you can press Alt+Down to see the list of all terminal tabs.
To rename a tab, right-click the tab and select Rename Session from the context menu.
Configure the terminal emulator
Project Settings
These settings affect the terminal only for the current project:
Specify the working directory where every new shell session should start. By default, it starts in the root directory of the current project.
Specify custom environment variables for every new shell session.
Application Settings
These settings affect the terminal in any project that you open with the current IntelliJ IDEA instance.
Specify the shell that will run by default. IntelliJ IDEA should automatically detect the default shell based on your environment. Here are some examples of different shells:
Bash for Windows: bash.exe
Command Prompt: cmd.exe
Specify the default name for new tabs.
Play the bell sound on various events.
Close session when it ends
Close the current session when the corresponding process ends (for example, by kill ).
Enable the mouse pointer support in the embedded local terminal.
Copy to clipboard on selection
Copy text selected in the terminal to the clipboard.
Paste on middle mouse button click
Paste clipboard contents by clicking the middle mouse button.
Override IDE shortcuts
Use shell-specific shortcuts instead of IDE shortcuts when the Terminal tool window is active.
Integrate the terminal with the system shell to properly keep track of your command history for sessions and load a custom config file with required environment variables.
Highlight HTTP links in the terminal and make them clickable.
Use Option as Meta key
On macOS, use the Option key as the Meta key.
Run Commands using IDE
Detect and highlight commands that can be used as IDE features instead of running them in the terminal and reading console output.
Select the shape of the cursor: block, underline, or vertical.
For the Python interpreter being a virtual environment, with this checkbox selected, the virtual environment is automatically activated ( activate is performed automatically).
This option is available only if you have the Python plugin installed.
The embedded terminal emulator also inherits the following IDE settings:
On the Keymap page, you can configure the copy Ctrl+C and paste Ctrl+V shortcuts.
On the Editor | General | Appearance page, you can configure blinking frequency for the caret. The Terminal does not inherit the Use block caret option because there is a separate option for that: Cursor shape.
On the Editor | Color Scheme | Console Font page, you can configure line spacing and fonts.
On the Editor | Color Scheme | Console Colors page, you can configure font colors.
On the Editor | Color Scheme | General page, you can configure the selection foreground and background colors.
Run IDE features from the terminal
Instead of running a specific command in the integrated terminal and reading console output, you can use the relevant IDE feature, like a tool window or a dialog that implements this functionality. For example, the diff viewer actually runs the diff command in the system shell to produce results. Another example is the Log tab in the Git tool window, which is based on the output of the git log command.
Open the Log tab of the Git tool window from the terminal
Type a supported command in the terminal and notice how it is highlighted.
Using the Terminal in IntelliJ IDEA
Read this post in other languages:
Français
In this video we’re going to take a look at IntelliJ IDEA’s built in terminal. This performs the same function as your operating system’s terminal or command feature, but using the terminal inside IntelliJ IDEA has a number of benefits.
Opening the IntelliJ IDEA Terminal Window
In this example we have a simple Spring Boot application that needs a running MongoDB database. We can open the terminal window with ⌥F12 on macOS, or Alt+F12 on Windows and Linux. The terminal supports all the same commands that the operating system supports.
If we want to start the MongoDB database instance with a specific path for storing the data, we can type:
and press enter. When MongoDB is running in the terminal session, we can go back to writing the application code in the editor. By using the built in terminal, we don’t have to switch between applications, and we can easily have all aspects of our development right in front of us in the same window.
Multiple Terminal Sessions
We can open a second terminal tab with ⌘T on macOS, or Ctrl+Shift+T on Windows and Linux, to run the MongoDB shell as a new command:
Then we can interact with the server that’s running, and check everything is OK for our application.
Running commands in different tabs is helpful, but sometimes two different processes are closely related and we want to see them together. For this, we can split our terminal window so that we can run two in the same window. For example, you can open up the mongo shell in this split window and can see if the commands have any impact on the running server.
Naming Terminal Tabs
We can run any type of command from the terminal window. For example, although IntelliJ IDEA has full integration with Gradle, sometimes we might want to check a build tool like Gradle or Maven runs correctly from the command line. We might sometimes do this with different Java versions or different arguments to those we’re using in the application. Given that we might be using a number of terminal sessions with a number of different processes or parameters, it’s useful to rename the tabs to something helpful. You can do this from the context menu, which you can open by right-clicking on the tab. That way we can easily reopen the one we’re interested in.
We can move between the different tabs with ⌘⇧[ or ⌘⇧] on macOS or Alt+← or Alt+→ on Windows and Linux. We can switch between the splits with ⌥⇥ on macOS, or Ctrl+Tab on Windows and Linux. We can close splits or tabs with ⌘W on macOS, or Ctrl+F4 for Windows and Linux.
When we restart IntelliJ IDEA, our terminal session names and other settings will persist.
Pasting Code from the Editor into the Terminal
Running command line processes from inside IntelliJ IDEA is useful for keeping us in the same context while we’re developing, and for sharing content between different parts of our application. For example, if we’re running the Java REPL JShell in an IntelliJ IDEA terminal window, it’s easy to copy code from the editor and paste it into JShell. This is not specific to running JShell in the terminal, it’s easy to copy and paste code from anywhere in IntelliJ IDEA into the terminal window.

View steps in video
Terminal Locations from the Command Window
The integration provided by the IDE also extends to being able to open a location from inside the project window in the terminal window from the context menu. Right click on an item in the Project Window, for example, and select «Open in Terminal». This means that we can have a terminal window in the correct location immediately without having to navigate using the command line.
URLs and Stack Traces in the Terminal Window
URLs in the terminal window are clickable, so we can click on any link shown in the terminal window to open them in the browser. File names in the terminal can also link back to the file in the project. In stack traces, you can click on the file name and IntelliJ IDEA will open the file and put the caret on the line that caused the problem. This takes some of the pain out of debugging problems.
Run IDE Features from the Terminal
You may notice that some commands in the terminal window are highlighted. This is a new feature in IntelliJ IDEA 2020.2 that shows that the command could be run in the IDE, meaning we don’t need to use the command line.
If it’s highlighted in yellow and we press Enter, the command will be run in the terminal window just as we’d expect. If we type the same command again, but this time use ⌘⏎ on macOS, or Ctrl+Enter on Windows and Linux, IntelliJ IDEA will use the feature in IntelliJ IDEA and open the relevant tool window.
IntelliJ IDEA detects a number of different commands that could be run in the IDE instead of from the command line. For example, the git command:
will execute normally if we press Enter. If we press ⌘⏎ on macOS, or Ctrl+Enter on Windows and Linux, it opens the Git log window in IntelliJ IDEA.
This is a great way to discover features in the IDE that are an alternative approach to using the command line. If we decide we’re not going to need these suggestions, we can turn off «Run IDE Features from the Terminal» from the terminal window’s settings using the context menu. The commands will no longer be highlighted.
Summary
IntelliJ IDEA’s terminal window is a powerful and helpful tool for developers. It keeps our attention in the same tools which reduces context switching. It makes it easy for us to share things between the editor and the command line. The terminal is integrated allowing us to easily move from the project code to the terminal and back again, and it also can show us alternative ways of doing the same thing, using the IDE’s version of the command line tool.
How to run using terminal on IntelliJ Idea using Maven?
I’m new to IntelliJ IDEA and I would like to run my test through the terminal lines.
I already run my test using the Run button and my test are all passed. Now, my requirement in project is to run using the command lines/terminal. I really don’t have any idea how to do it.
I’m using Appium as my tool for mobile automation.
This is all where my tests are located, C:\Users\ereyne\IdeaProjects\ioappium\src\test\java\io
I already look on google but all are in high level, can anyone provide me step by step process on how to do it? Test java classes
This is my code in IntelliJ:
I run this is terminal: C:\Users\ereyne\IdeaProjects\ioappium>mvn appium.java
I also try to run this in my terminal: C:\Users\ereyne\IdeaProjects\ioappium\src\test\java\io>javac appium.java
And the result is everything does not exist, just a sample error below.
appium.java:2: error: package io.appium.java_client does not exist import io.appium.java_client.MobileBy;
1 Answer 1
IntelliJ-IDEA actually has a built-in terminal that you can run maven commands in at a project level. Simply click the «terminal» button on the very bottom bar. If you don’t see it, try «Alt+F12». If your terminal is disabled, press Shift twice, type «Terminal» and turn it on.
From there, you can run maven commands. The valid lifecycle phases are:
So within that terminal, you’ll already be on the right directory, and can run valid maven commands. For example
You will want the Maven-Compiler-Plugin, and either the Maven-Surefire-Plugin or Maven-Failsafe-plugin. For my own personal project, this is the pom.xml that I use containing those plugins.
The ‘source’ and ‘target’ denote what Java version my project uses. These plugins allow me to both run my project as a maven project, and have specific things happen at different instances of the lifecycle.
In my case, during the «verify» phase, maven triggers a plugin of mine to log results, and create a report.
If you’re getting the error
‘mvn’ is not recognized as an internal or external command, operable program or batch file.
This means that Maven was not added to your PATH correctly. It can be a little confusing, but this video helped me a lot.
If you want to check your maven installation, open a new terminal, and run the following
You should get the response (with your system details)
Edit: To answer your question below in more detail, I use a TestRunner class designed for the Cucumber framework, and I do not have a main method in my program at all. My Test class is as follows:
As you can see, my Test class doesn’t have any code inside of it, and simply points to specific tests that I’ve built, and executes those. In the case of using TestNG as a test suite, it will look a lot different, and is a little bit easier to understand what is being tested, but check these resources to make sure you understand what to do.
Based on your reply, odds are, you’ve already got a TestNG suite built, and just need to tie it into maven.
The structure of a pom.xml is fairly straightforward, so you can use this to help you put the plugins you need into yours. I’ve included a copy of my pom.xml for a testing suite using Cucumber and Appium, just so you can see the format. I highly encourage you to keep the comments including the repository information in the event you need to update them in a hurry.
As you can see, in my pom.xml I have a plugin that generates a test report during the «Verify» phase of Maven. When I want to run a test, I will run
This clears out any of my old test results, and runs the maven «Verify» cycle. Verify will run the tests I specify, and then depending on the results of my tests, the maven build will either succeed or fail.
If you see a maven build failure, that doesn’t mean your code failed to execute, it means that maven had a reason to fail a build. Read about the specific maven plugins and lifecycle phases to understand what causes build failures, and what behaviors to expect out of maven.

















