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
Summary
Since kitty 0.47.0,
omarchy-cmd-terminal-cwdalways 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 fromboss.py:It's spawned after the shell, so it has a higher PID and
tail -n1selects it:/usr/bin/kittenisn'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, sotail -n1worked 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:
This also tightens the shell check: the current
grep -qs "$shell" /etc/shellstreats the path as a regex and matches substrings, so/bin/shmatches a/bin/shell-fooline.grep -qsxFmatches the full line literally.Environment
bec26eea)