Skip to content

omarchy-cmd-terminal-cwd returns $HOME on kitty >= 0.47 — Super+Enter no longer opens in current directory #6230

Description

@gusevdigital

Summary

Since kitty 0.47.0, omarchy-cmd-terminal-cwd always falls back to $HOME, so Super+Enter opens a new terminal in the home directory instead of the active terminal's cwd. Super+Alt+Enter (tmux) and Super+Alt+Shift+F (Nautilus in cwd) are affected too, since they call the same command.

Cause

The script picks the shell by taking the terminal's highest-numbered child PID:

shell_pid=$(pgrep -P "$terminal_pid" | tail -n1)

kitty 0.47.0 added auto config reloading (auto_reload_config, enabled by default), which spawns a long-lived helper from boss.py:

if opts.auto_reload_config >= 0 and not hasattr(self, 'config_reload_watcher_process') and opts.all_config_paths:
    self.config_reload_watcher_process = subprocess.Popen(
        [kitten_exe(), '__watch_conf__', str(os.getpid()), ...])

It's spawned after the shell, so it has a higher PID and tail -n1 selects it:

192573  kitten __atexit__
192575  bash                    <- actual shell
192581  kitten __watch_conf__   <- tail -n1 picks this

/usr/bin/kitten isn't in /etc/shells, so the guard fails and the script echoes $HOME. On kitty <= 0.46 the shell happened to be the last child, so tail -n1 worked by coincidence.

Only reproduced on kitty. ghostty and alacritty likely don't spawn a config watcher and are probably unaffected.

Suggested fix

Scan every child and take the first one that is a real shell, rather than relying on PID ordering:

terminal_pid=$(hyprctl activewindow | awk '/pid:/ {print $2}')

if [[ -n $terminal_pid ]]; then
  for pid in $(pgrep -P "$terminal_pid"); do
    shell=$(readlink -f "/proc/$pid/exe" 2>/dev/null)
    grep -qsxF "$shell" /etc/shells || continue

    cwd=$(readlink -f "/proc/$pid/cwd" 2>/dev/null)
    if [[ -d $cwd ]]; then
      echo "$cwd"
      exit 0
    fi
  done
fi

echo "$HOME"

This also tightens the shell check: the current grep -qs "$shell" /etc/shells treats the path as a regex and matches substrings, so /bin/sh matches a /bin/shell-foo line. grep -qsxF matches the full line literally.

Environment

  • Omarchy 3.8.3 (bec26eea)
  • kitty 0.47.4-1
  • Hyprland 0.55.4
  • Arch Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions