Skip to content

Commit

Permalink
Merge pull request #48 from SergejT34/main
Browse files Browse the repository at this point in the history
Support for Alacritty, Hyper & Kitty MacOS terminals
  • Loading branch information
siarheiburliayeu authored Oct 10, 2023
2 parents 776b8d3 + 4a84151 commit f61a5af
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ patchPluginXml {
<br>
<br>If you want to use another terminal instead - you can!
<br>Just specify your favorite one in the <strong>IDE Settings / Preferences</strong>.
<br><i>*PowerShell, ConEmu, Cmder, WSL, GitBash, RXVT, iTerm, kitty, Terminator are also supported.</i>
<br><i>*PowerShell, ConEmu, Cmder, WSL, GitBash, RXVT, iTerm, kitty, Terminator, Alacritty, Hyper are also supported.</i>
<br>
<br>Since <strong>version 0.4</strong>, it is available to specify a custom command with \${project.dir} placeholder,
which will be replaced at runtime with the actual project directory.
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Adds a Terminal icon to the IDE toolbar and context menu to open project directo

If you want to use another terminal instead - you can!
<br>Just specify your favorite one in the **IDE Settings / Preferences**.
<br>_*PowerShell, ConEmu, Cmder, WSL (bash, wsl), GitBash, RXVT, iTerm are also supported._
<br>_*PowerShell, ConEmu, Cmder, WSL (bash, wsl), GitBash, RXVT, iTerm, Alacritty, Kitty, Hyper are also supported._
<br>
<br>Since **version 0.4**, it is available to specify a custom command with `${project.dir}` placeholder,
which will be replaced at runtime with the actual project directory.
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 @@ -96,8 +96,12 @@ public static Command createCommand(@NotNull Environment env,

case MAC_OS:
switch (terminal) {
case ALACRITTY:
return new Command("open", "-n", "-a", command, "--args", "--working-directory", projectDirectory);
case MAC_TERMINAL:
case I_TERM:
case KITTY:
case HYPER:
default:
return new Command("open", projectDirectory, "-a", command);
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/sburlyaev/cmd/plugin/model/Terminal.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public enum Terminal {
// macOS
MAC_TERMINAL("Terminal"),
I_TERM("iTerm"),
ALACRITTY("Alacritty"),
HYPER("Hyper"),

GENERIC("");

Expand Down
33 changes: 33 additions & 0 deletions src/test/java/com/sburlyaev/cmd/plugin/CommandBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,39 @@ public void testCreateCommandForMacOsITerm() throws FileNotFoundException {
assertEquals(expected, result.getCommands());
}

@Test
@Ignore
public void testCreateCommandForMacOsAlacritty() throws FileNotFoundException {
Environment env = new Environment(OperationSystem.MAC_OS, "13.3", "X");
String projectBaseDir = "/user/home/IdeaProjects/IDEA-Native-Terminal-Plugin";
Command result = CommandBuilder.createCommand(env, projectBaseDir, "Alacritty");

String expected = MessageFormat.format("open -n -a Alacritty --args --working-directory {0}", projectBaseDir);
assertEquals(expected, result.getCommands());
}

@Test
@Ignore
public void testCreateCommandForMacOsKitty() throws FileNotFoundException {
Environment env = new Environment(OperationSystem.MAC_OS, "13.3", "X");
String projectBaseDir = "/user/home/IdeaProjects/IDEA-Native-Terminal-Plugin";
Command result = CommandBuilder.createCommand(env, projectBaseDir, "kitty");

String expected = MessageFormat.format("open ''{0}'' -a kitty", projectBaseDir);
assertEquals(expected, result.getCommands());
}

@Test
@Ignore
public void testCreateCommandForMacOsHyper() throws FileNotFoundException {
Environment env = new Environment(OperationSystem.MAC_OS, "13.3", "X");
String projectBaseDir = "/user/home/IdeaProjects/IDEA-Native-Terminal-Plugin";
Command result = CommandBuilder.createCommand(env, projectBaseDir, "hyper");

String expected = MessageFormat.format("open ''{0}'' -a Hyper", projectBaseDir);
assertEquals(expected, result.getCommands());
}

@Test
@Ignore
public void testCheckProjectDirectory() throws FileNotFoundException {
Expand Down
18 changes: 18 additions & 0 deletions src/test/java/com/sburlyaev/cmd/plugin/model/TerminalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,22 @@ public void testFromStringITerm() {
assertEquals(Terminal.I_TERM, result);
}

@Test
public void testFromStringIAlacritty() {
Terminal result = Terminal.fromString("Alacritty");
assertEquals(Terminal.ALACRITTY, result);
}

@Test
public void testFromStringIKitty() {
Terminal result = Terminal.fromString("kitty");
assertEquals(Terminal.KITTY, result);
}

@Test
public void testFromStringIHyper() {
Terminal result = Terminal.fromString("Hyper");
assertEquals(Terminal.HYPER, result);
}

}

0 comments on commit f61a5af

Please sign in to comment.