From dd5881f9ad618203d5d2e658a40d19cc2ef0c4c8 Mon Sep 17 00:00:00 2001 From: crschnick Date: Sat, 9 Nov 2024 04:08:04 +0000 Subject: [PATCH] Adjust terminal hierarchies --- .../app/terminal/ExternalTerminalType.java | 17 +++++++++++++++++ .../xpipe/app/terminal/KittyTerminalType.java | 5 +++++ .../io/xpipe/app/terminal/TerminalView.java | 4 ++++ 3 files changed, 26 insertions(+) diff --git a/app/src/main/java/io/xpipe/app/terminal/ExternalTerminalType.java b/app/src/main/java/io/xpipe/app/terminal/ExternalTerminalType.java index f381d529a..9ac30d3a9 100644 --- a/app/src/main/java/io/xpipe/app/terminal/ExternalTerminalType.java +++ b/app/src/main/java/io/xpipe/app/terminal/ExternalTerminalType.java @@ -803,6 +803,12 @@ public interface ExternalTerminalType extends PrefsChoiceValue { } }; ExternalTerminalType MACOS_TERMINAL = new MacOsType("app.macosTerminal", "Terminal") { + + @Override + public int getProcessHierarchyOffset() { + return 2; + } + @Override public boolean supportsTabs() { return false; @@ -828,6 +834,12 @@ public interface ExternalTerminalType extends PrefsChoiceValue { } }; ExternalTerminalType ITERM2 = new MacOsType("app.iterm2", "iTerm") { + + @Override + public int getProcessHierarchyOffset() { + return 3; + } + @Override public String getWebsite() { return "https://iterm2.com/"; @@ -859,6 +871,11 @@ public interface ExternalTerminalType extends PrefsChoiceValue { }; ExternalTerminalType WARP = new MacOsType("app.warp", "Warp") { + @Override + public int getProcessHierarchyOffset() { + return 2; + } + @Override public String getWebsite() { return "https://www.warp.dev/"; diff --git a/app/src/main/java/io/xpipe/app/terminal/KittyTerminalType.java b/app/src/main/java/io/xpipe/app/terminal/KittyTerminalType.java index 0ca65961a..c2372724b 100644 --- a/app/src/main/java/io/xpipe/app/terminal/KittyTerminalType.java +++ b/app/src/main/java/io/xpipe/app/terminal/KittyTerminalType.java @@ -154,6 +154,11 @@ public interface KittyTerminalType extends ExternalTerminalType { super("app.kitty", "kitty"); } + @Override + public int getProcessHierarchyOffset() { + return 1; + } + @Override public void launch(LaunchConfiguration configuration) throws Exception { // We use the absolute path to force the usage of macOS netcat diff --git a/app/src/main/java/io/xpipe/app/terminal/TerminalView.java b/app/src/main/java/io/xpipe/app/terminal/TerminalView.java index 6c4beef20..419797164 100644 --- a/app/src/main/java/io/xpipe/app/terminal/TerminalView.java +++ b/app/src/main/java/io/xpipe/app/terminal/TerminalView.java @@ -132,6 +132,10 @@ public class TerminalView { } var off = trackableTerminalType.getProcessHierarchyOffset(); + if (AppPrefs.get().enableTerminalLogging().get() && OsType.getLocal() != OsType.WINDOWS) { + off += 2; + } + var current = Optional.of(shell); for (int i = 0; i < 1 + off; i++) { current = current.flatMap(processHandle -> processHandle.parent());