Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 如何在IntelliJ中运行程序时启动终端或命令窗口_Macos_Intellij Idea - Fatal编程技术网

Macos 如何在IntelliJ中运行程序时启动终端或命令窗口

Macos 如何在IntelliJ中运行程序时启动终端或命令窗口,macos,intellij-idea,Macos,Intellij Idea,我正在编写一个命令行程序,希望每当我运行我的程序时,终端自动打开。这在IntelliJ中是否可行?是的,您可以 使用此代码(您需要一个Project实例,您可以从ActionEvent.getProject获取它): 哦,我的意思是osx终端使用某种形式的intelliJ配置,我知道一些IDE有这种配置,我想intelliJ可能是什么意思,你说的“osx终端使用某种形式的配置”取决于什么。你是怎么运作的?例如,您可以配置执行该命令的。 GeneralCommandLine commandLine

我正在编写一个命令行程序,希望每当我运行我的程序时,终端自动打开。这在IntelliJ中是否可行?

是的,您可以

使用此代码(您需要一个
Project
实例,您可以从
ActionEvent.getProject
获取它):


哦,我的意思是osx终端使用某种形式的intelliJ配置,我知道一些IDE有这种配置,我想intelliJ可能是什么意思,你说的“osx终端使用某种形式的配置”取决于什么。你是怎么运作的?例如,您可以配置执行该命令的。
GeneralCommandLine commandLine = new GeneralCommandLine([List of your command line arguments]);
OSProcessHandler handler = new OSProcessHandler(commandLine);
TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
ConsoleView console = consoleBuilder.getConsole();
Executor executor = DefaultRunExecutor.getRunExecutorInstance();
DefaultActionGroup actionGroup = new DefaultActionGroup();
BorderLayoutPanel component = JBUI.Panels.simplePanel();
component = component.addToCenter(console.getComponent());
ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("MainToolbar", actionGroup, false);
RunContentDescriptor descriptor = new RunContentDescriptor(console,
        handler,
        component.addToLeft(toolbar.getComponent()),
        [Your title],
        [Your icon]);
ExecutionManager manager = ExecutionManager.getInstance(project);
manager.getContentManager().showRunContent(executor, descriptor);
AnAction[] consoleActions = console.createConsoleActions();

for (AnAction action : consoleActions) actionGroup.add(action);

actionGroup.add(new PinActiveTabAction());
actionGroup.add(new CloseAction(executor, descriptor, project));
console.allowHeavyFilters();
console.attachToProcess(handler);
ProcessTerminatedListener.attach(handler);
handler.startNotify();