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());