Avoid invalid terminal working directory (#3428)

Don't use the working directory of the last child of the active window
when opening a new terminal with Super+Enter.

Fixes #3427.
This commit is contained in:
David Wales
2025-11-17 00:18:56 -08:00
committed by GitHub
parent 88684b6dd0
commit e1745d7ff9

View File

@@ -6,8 +6,10 @@ shell_pid=$(pgrep -P "$terminal_pid" | tail -n1)
if [[ -n $shell_pid ]]; then if [[ -n $shell_pid ]]; then
cwd=$(readlink -f "/proc/$shell_pid/cwd" 2>/dev/null) cwd=$(readlink -f "/proc/$shell_pid/cwd" 2>/dev/null)
shell=$(readlink -f "/proc/$shell_pid/exe" 2>/dev/null)
if [[ -d $cwd ]]; then # Check if $shell is a valid shell and $cwd is a directory.
if grep -qs "$shell" /etc/shells && [[ -d $cwd ]]; then
echo "$cwd" echo "$cwd"
else else
echo "$HOME" echo "$HOME"