Java终端模式小尝试

Java终端模式小尝试

  • 1、IDE中终端
    • 1.1 拉去代码 jediterm
    • 1.2 IDE调用系统终端
  • 2、待续~~

1、IDE中终端

终端_Intellij IDEA、Terminal emulator | pycharm Documentation
JetBrains jediterm
WindTerm:新一代开源免费的终端工具,GitHub星标6.6k+,太酷了! (https://github.com/kingToolbox/WindTerm)

1.1 拉去代码 jediterm

克隆失败,只能下载导入-_-
Java终端模式小尝试_第1张图片
Java终端模式小尝试_第2张图片

1.2 IDE调用系统终端

com/jediterm/app/JediTermMain.kt 在Windows使用"powershell.exe"

  override fun createTtyConnector(): TtyConnector {
    try {
      val envs: Map<String, String> = configureEnvironmentVariables()
      val command: Array<String> = if (Platform.current() == Platform.Windows) {
        arrayOf("powershell.exe")
      }
      else {
        val shell = envs["SHELL"] ?: "/bin/bash"
        if (Platform.current() == Platform.Mac) arrayOf(shell, "--login") else arrayOf(shell)
      }
      val workingDirectory = Path.of(".").toAbsolutePath().normalize().pathString

      LOG.info("Starting ${command.joinToString()} in $workingDirectory")
      val process = PtyProcessBuilder()
        .setDirectory(workingDirectory)
        .setInitialColumns(120)
        .setInitialRows(20)
        .setCommand(command)
        .setEnvironment(envs)
        .setConsole(false)
        .setUseWinConPty(true)
        .start()

      return LoggingPtyProcessTtyConnector(process, StandardCharsets.UTF_8, command.toList())
    }
    catch (e: Exception) {
      throw IllegalStateException(e)
    }

  }

2、待续~~

你可能感兴趣的:(Java,Java)