Skip to content

Limit terminal cwd inheritance to terminal windows - #10872

Open
Drecullith wants to merge 1 commit into
omacom:quattrofrom
Drecullith:fix/terminal-cwd-focused-window
Open

Limit terminal cwd inheritance to terminal windows#10872
Drecullith wants to merge 1 commit into
omacom:quattrofrom
Drecullith:fix/terminal-cwd-focused-window

Conversation

@Drecullith

Copy link
Copy Markdown

Summary

Prevent omarchy-cmd-terminal-cwd from inheriting the working directory of an arbitrary shell process owned by the focused application.

Previously the helper took the focused window PID, selected one of its child processes, and accepted that child's cwd whenever its executable appeared in /etc/shells. This meant a non-terminal application such as a browser could accidentally be treated as a terminal if it happened to own a helper bash process.

For example, a browser download helper running from ~/Downloads could cause SUPER+ENTER to open a new terminal there even though no terminal window was focused.

This change:

  • reads the active window through hyprctl -j activewindow;
  • uses Omarchy's existing terminal Hyprland tag as the primary terminal classification, matching the universal clipboard bindings;
  • handles dynamic tags with their trailing *;
  • falls back to $HOME before inspecting child processes when a non-terminal window is focused;
  • preserves the existing Kitty remote-control cwd path and generic shell-child fallback for actual terminals;
  • accepts WezTerm's canonical org.wezfurlong.wezterm Wayland app_id as a compatibility fallback while older terminal rules may not tag it yet.

Fixes #10840.

Tests

Added test/shell.d/terminal-cwd-test.sh covering:

  • a non-terminal browser window with a child shell does not leak that shell's cwd;
  • child processes of non-terminal windows are not inspected;
  • dynamically tagged terminal* windows inherit cwd;
  • normally tagged terminal windows inherit cwd;
  • canonical Wayland WezTerm continues to inherit cwd even before its terminal tag is present.

The focused regression test passes locally, and both changed shell scripts pass Bash syntax validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SUPER+ENTER abre terminal no cwd de um processo auxiliar da janela focada (ex: download do Edge em ~/Downloads)

1 participant