Skip to content

Commit

Permalink
Add 'Windows Terminal' and improve support for other new terminals
Browse files Browse the repository at this point in the history
  • Loading branch information
siarheiburliayeu committed Apr 17, 2020
1 parent 3e73c4f commit e3dfa23
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ patchPluginXml {
which will be replaced at runtime with the actual project directory.
"""
changeNotes """
- Improved WSL support (wsl, wsl.exe).
- Improved support for 'Windows Terminal' and other new terminals.
"""
}
4 changes: 4 additions & 0 deletions src/main/java/com/sburlyaev/cmd/plugin/CommandBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public static Command createCommand(@NotNull Environment env,

Terminal terminal = Terminal.fromString(command);
log.info("Favorite terminal is [" + favoriteTerminalString + "] and using [" + terminal + "]");
log.info("Project directory: " + projectDirectory);

OperationSystem os = env.getOs();
switch (os) {
Expand All @@ -49,6 +50,9 @@ public static Command createCommand(@NotNull Environment env,
return new Command("cmd", "/c", "start", command, "-NoExit", "-Command",
"Set-Location", "'" + projectDirectory + "'");

case WINDOWS_TERMINAL:
return new Command(command, "-d", projectDirectory);

case CON_EMU:
String conEmuRunCommand = " -run ";
String[] commands = command.split(conEmuRunCommand);
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/sburlyaev/cmd/plugin/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ public static void main(String[] args) throws IOException {
System.out.println("/usr/bin/gnome-terminal: " + new File("/usr/bin/gnome-terminal").exists());
System.out.println("/usr/bin/konsole: " + new File("/usr/bin/konsole").exists());

String command1 = "konsole";
String command2 = "--new-tab";
String command3 = "--workdir";
String command4 = System.getProperty("user.dir");
String dir = System.getProperty("user.dir");

Command command = new Command(command1, command2, command3, command4);
Command command = new Command("wt", "-d", dir);
System.out.println(command);
System.out.println(dir);
command.execute();
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/sburlyaev/cmd/plugin/model/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ public void add(String... commands) {
this.commands.addAll(Arrays.asList(commands));
}

@Deprecated
public void execute() throws IOException {
new ProcessBuilder(commands)
.start();
}

public void execute(String path) throws IOException {
new ProcessBuilder(commands).directory(new File(path))
new ProcessBuilder(commands)
.directory(new File(path))
.start();
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/sburlyaev/cmd/plugin/model/Terminal.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
public enum Terminal {
// Windows
CMDER("cmder"),
WINDOWS_TERMINAL("wt"),
COMMAND_PROMPT("cmd"),
POWER_SHELL("powershell"),
CON_EMU("conemu"),
Expand Down

0 comments on commit e3dfa23

Please sign in to comment.