From d7263b8c51c83dc68006b6ae29feaee83b8d88b2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Av=C3=A9?= <email@thomasave.be>
Date: Sun, 17 Sep 2023 20:54:52 +0200
Subject: [PATCH 1/2] Save PID of SSH connection

---
 zsh/.zshrc | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/zsh/.zshrc b/zsh/.zshrc
index 5f62286..b43400d 100644
--- a/zsh/.zshrc
+++ b/zsh/.zshrc
@@ -167,6 +167,11 @@ function o () {
 	xdg-open "$1" &!
 }
 
+if [ "$SSH_CLIENT" ]
+then
+    source_port=$(echo $SSH_CLIENT | awk '{ print $2 }')
+    echo $$ > /tmp/ssh_session_$source_port
+fi
 
 if [[ "$TERM" == (Eterm*|alacritty*|aterm*|gnome*|konsole*|kterm*|putty*|rxvt*|screen*|tmux*|xterm*) ]]; then
 	add-zsh-hook -Uz precmd xterm_title_precmd

From 741d0f4d1e7ed8ddc02dd737d96e8b742ef9887f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Av=C3=A9?= <email@thomasave.be>
Date: Sun, 17 Sep 2023 21:08:00 +0200
Subject: [PATCH 2/2] Escape paths to allow for spaces

---
 awesome/scripts/launch_alacritty.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/awesome/scripts/launch_alacritty.sh b/awesome/scripts/launch_alacritty.sh
index 7b2f2b5..72bbd39 100755
--- a/awesome/scripts/launch_alacritty.sh
+++ b/awesome/scripts/launch_alacritty.sh
@@ -10,7 +10,7 @@ then
     if [ $PROCESS == "ssh" ]
     then
         PORT=$(ss -tnpa | grep ssh | grep "pid=$GRAND_CHILD_PID" | awk '{ print $4 }' | grep -o '[0-9]*$')
-        alacritty -e $COMMAND -t "cd \$(readlink -e /proc/\$(cat /tmp/ssh_session_$PORT)/cwd); zsh --login"
+        alacritty -e $COMMAND -t "cd \"\$(readlink -e /proc/\$(cat /tmp/ssh_session_$PORT)/cwd)\"; zsh --login"
         exit 0
     fi
 fi