- теперь терминал открывается сразу в папке проекта

This commit is contained in:
stud_i_sram 2026-05-15 16:33:56 +03:00
parent d54e9dd058
commit 1d4c3fa904
2 changed files with 12 additions and 2 deletions

View File

@ -48,7 +48,7 @@ public class OpenRemoteTerminalAction extends AnAction {
SftpSessionManager.getInstance(project)
.getShellChannel(server);
TtyConnector connector = new SshTtyConnector(shellChannel);
TtyConnector connector = new SshTtyConnector(shellChannel, server.remoteProjectPath);
ToolWindow terminalToolWindow =
ToolWindowManager.getInstance(project).getToolWindow("Terminal");

View File

@ -15,12 +15,22 @@ public class SshTtyConnector implements TtyConnector {
private final OutputStream outputStream;
private final Reader reader;
public SshTtyConnector(ChannelShell channel) {
public SshTtyConnector(ChannelShell channel, String initialPath) {
this.channel = channel;
try {
this.inputStream = channel.getInputStream();
this.outputStream = channel.getOutputStream();
this.reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
if (initialPath != null && !initialPath.isBlank()) {
outputStream.write(
("cd \"" + initialPath + "\"\n")
.getBytes(StandardCharsets.UTF_8)
);
outputStream.flush();
}
} catch (Exception e) {
throw new RuntimeException(e);
}