mirror of
https://github.com/basecamp/omarchy.git
synced 2026-02-17 15:25:37 +00:00
Don't use the working directory of the last child of the active window when opening a new terminal with Super+Enter. Fixes #3427.
20 lines
537 B
Bash
Executable File
20 lines
537 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Go from current active terminal to its child shell process and run cwd there
|
|
terminal_pid=$(hyprctl activewindow | awk '/pid:/ {print $2}')
|
|
shell_pid=$(pgrep -P "$terminal_pid" | tail -n1)
|
|
|
|
if [[ -n $shell_pid ]]; then
|
|
cwd=$(readlink -f "/proc/$shell_pid/cwd" 2>/dev/null)
|
|
shell=$(readlink -f "/proc/$shell_pid/exe" 2>/dev/null)
|
|
|
|
# Check if $shell is a valid shell and $cwd is a directory.
|
|
if grep -qs "$shell" /etc/shells && [[ -d $cwd ]]; then
|
|
echo "$cwd"
|
|
else
|
|
echo "$HOME"
|
|
fi
|
|
else
|
|
echo "$HOME"
|
|
fi
|