From ce52cd1c69d45a1c234ac521ea50b352b67f12a4 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Tue, 9 Jul 2024 10:40:38 +1000 Subject: [PATCH] Use default Kitty socket path rather than XDG_CACHE_HOME --- dot-local/bin/kit | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dot-local/bin/kit b/dot-local/bin/kit index 3127897..a540c0c 100755 --- a/dot-local/bin/kit +++ b/dot-local/bin/kit @@ -1,5 +1,4 @@ #!/bin/zsh -: ${XDG_CACHE_HOME:=~/.cache} MAC_KITTY=/Applications/kitty.app/Contents/MacOS if (( $+commands[kitty] == 0 )); then @@ -10,4 +9,12 @@ if (( $+commands[kitty] == 0 )); then exit 1 fi fi -exec kitty @ --to unix:$XDG_CACHE_HOME/kitty/kitty.sock "$@" + +# Sort the sockets youngest-first, because the youngest one is most likely to be still alive. +sockets=( ${TMPDIR}/kitty-socket-*(om) ) +if (( $#sockets < 1 )); then + print "Sorry, no Kitty socket could be found. Check $TMPDIR for 'kitty-socket' files." >&2 + exit 2 +fi + +exec kitty @ --to unix:$sockets[1] "$@"