From 316eefe916f83611258608d978cdad36a9942dae Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Thu, 11 Dec 2025 15:26:32 +0100 Subject: [PATCH] kitty:get_cwd: Use KITTY_LISTEN_ON for socket path Also verify that the socket exists before using it. --- .config/kitty/get_cwd.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.config/kitty/get_cwd.sh b/.config/kitty/get_cwd.sh index c89ab6a..3a02af3 100755 --- a/.config/kitty/get_cwd.sh +++ b/.config/kitty/get_cwd.sh @@ -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.