kitty:get_cwd: Use KITTY_LISTEN_ON for socket path

Also verify that the socket exists before using it.
This commit is contained in:
2025-12-11 15:26:32 +01:00
parent 3a821d832b
commit 316eefe916

View File

@@ -7,7 +7,12 @@
# Print the current working directory of the focused kitty window. Returns 4 if
# none exist or is focused.
socket_path="${TMPDIR:-/tmp}/kitty.$USER/kitty${1:+-$1}.sock"
if [ -n "$KITTY_LISTEN_ON" ]; then
socket_path="${KITTY_LISTEN_ON#unix:}"
else
socket_path="${TMPDIR:-/tmp}/kitty.$USER/kitty${1:+-$1}.sock"
fi
[ -e "$socket_path" ] || exit 1
# NOTE: Unfortunately kitten-@-ls(1) is slow, so communicate with the socket
# directly.