[Intellij IDEA Plugin]获取Terminal

ToolWindow terminal = ToolWindowManager.getInstance(anActionEvent.getProject()).getToolWindow("Terminal");
        JComponent root = terminal.getComponent();
        terminal.show(() -> {
            JBTerminalPanel terminalPanel = ((JBTerminalPanel)((JLayeredPane)((JPanel)((JPanel)((JPanel)((JPanel)((JPanel)((JPanel)root.getComponent(0)).getComponent(0)).getComponent(0)).getComponent(0)).getComponent(0)).getComponent(0)).getComponent(0)).getComponent(0));
            //执行history命令
            terminalPanel.getTerminalOutputStream().sendString("history \n");
        });

推荐阅读更多精彩内容