mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 00:50:31 +00:00
Add windows terminal preview support
This commit is contained in:
parent
d9f1a5a769
commit
f467d59f49
1 changed files with 41 additions and 3 deletions
|
@ -13,6 +13,7 @@ import lombok.Getter;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -88,6 +89,43 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ExternalTerminalType WINDOWS_TERMINAL_PREVIEW = new ExternalTerminalType() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void launch(LaunchConfiguration configuration) throws Exception {
|
||||||
|
// A weird behavior in Windows Terminal causes the trailing
|
||||||
|
// backslash of a filepath to escape the closing quote in the title argument
|
||||||
|
// So just remove that slash
|
||||||
|
var fixedName = FileNames.removeTrailingSlash(configuration.getTitle());
|
||||||
|
LocalShell.getShell()
|
||||||
|
.executeSimpleCommand(CommandBuilder.of()
|
||||||
|
.addFile(getPath().toString())
|
||||||
|
.add("-w", "1", "nt", "--title")
|
||||||
|
.addQuoted(fixedName)
|
||||||
|
.addFile(configuration.getScriptFile()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Path getPath() {
|
||||||
|
var local = System.getenv("LOCALAPPDATA");
|
||||||
|
return Path.of(local).resolve("Microsoft\\WindowsApps\\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\\wt.exe");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAvailable() {
|
||||||
|
return Files.exists(getPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSelectable() {
|
||||||
|
return OsType.getLocal().equals(OsType.WINDOWS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
return "app.windowsTerminalPreview";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
ExternalTerminalType WINDOWS_TERMINAL = new PathType("app.windowsTerminal", "wt.exe") {
|
ExternalTerminalType WINDOWS_TERMINAL = new PathType("app.windowsTerminal", "wt.exe") {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -195,9 +233,8 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void execute(Path file, LaunchConfiguration configuration) throws Exception {
|
protected void execute(Path file, LaunchConfiguration configuration) throws Exception {
|
||||||
ThreadHelper.runFailableAsync(() -> {
|
new LocalStore().control().command(CommandBuilder.of().addFile(file.toString()).add("start")
|
||||||
new LocalStore().control().command(CommandBuilder.of().addFile(file.toString()).add("start").addFile(configuration.getScriptFile())).execute();
|
.addFile(configuration.getScriptFile())).execute();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -566,6 +603,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
||||||
TABBY_WINDOWS,
|
TABBY_WINDOWS,
|
||||||
ALACRITTY_WINDOWS,
|
ALACRITTY_WINDOWS,
|
||||||
WEZ_WINDOWS,
|
WEZ_WINDOWS,
|
||||||
|
WINDOWS_TERMINAL_PREVIEW,
|
||||||
WINDOWS_TERMINAL,
|
WINDOWS_TERMINAL,
|
||||||
PWSH_WINDOWS,
|
PWSH_WINDOWS,
|
||||||
POWERSHELL_WINDOWS,
|
POWERSHELL_WINDOWS,
|
||||||
|
|
Loading…
Reference in a new issue