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