fix current working directory if readlink doesn't return a valid directory (#1940)

This commit is contained in:
Matt Harrison
2025-10-07 09:36:17 -04:00
committed by GitHub
parent e6d1a2f754
commit f956233ecf

View File

@@ -5,7 +5,12 @@ terminal_pid=$(hyprctl activewindow | awk '/pid:/ {print $2}')
shell_pid=$(pgrep -P "$terminal_pid" | head -n1)
if [[ -n $shell_pid ]]; then
readlink -f "/proc/$shell_pid/cwd" 2>/dev/null || echo "$HOME"
found_cwd=$(readlink -f "/proc/$shell_pid/cwd" 2>/dev/null || echo "$HOME")
if [[ -d "$found_cwd" ]]; then
echo "$found_cwd"
else
echo "$HOME"
fi
else
echo "$HOME"
fi