From 6e63a19f043dda9a0538d06d0d5ac39a1524a20b Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Fri, 21 Jun 2024 18:40:01 +0200 Subject: [PATCH] Fix bugs --- bin/clone-terminal | 3 ++- zsh/preserve-cwd-ssh.zsh | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/bin/clone-terminal b/bin/clone-terminal index 7803e67..f1acc11 100755 --- a/bin/clone-terminal +++ b/bin/clone-terminal @@ -4,11 +4,12 @@ WINDOW_ID=$(xdotool getactivewindow) WM_NAME=$(xprop -id $WINDOW_ID WM_NAME | cut -d '"' -f 2) uuid=$(uuidgen) + notify-send $WM_NAME you if [ -f $HOME/.config/terminalscwd/$WM_NAME.ssh ]; then cp $HOME/.config/terminalscwd/$WM_NAME.ssh $HOME/.config/terminalscwd/$uuid.ssh alacritty --title $uuid -e sh -c "TERMINAL_UUID=$uuid PARENT_TERMINAL=$WM_NAME ssh $(cat $HOME/.config/terminalscwd/$WM_NAME.ssh)" else cp $HOME/.config/terminalscwd/$WM_NAME.pwd $HOME/.config/terminalscwd/$uuid.pwd - alacritty --title uuid -e sh -c "PARENT_TERMINAL=$WM_NAME exec $SHELL" + alacritty --title $uuid -e sh -c "TERMINAL_UUID=$uuid PARENT_TERMINAL=$WM_NAME exec $SHELL" fi diff --git a/zsh/preserve-cwd-ssh.zsh b/zsh/preserve-cwd-ssh.zsh index bc3d0ae..866722b 100644 --- a/zsh/preserve-cwd-ssh.zsh +++ b/zsh/preserve-cwd-ssh.zsh @@ -1,11 +1,16 @@ if [ "$PRESERVE_SSH_CWD" = "true" ]; then - if [ -z $TERMINAL_UUID ]; then - if [ -z $DISPLAY ]; then + if [ -z $DISPLAY ]; then + if [ -z $TERMINAL_UUID ]; then export TERMINAL_UUID=$(uuidgen) - else - WINDOW_ID=$(xdotool getactivewindow) + fi + else + WINDOW_ID=$(xdotool getactivewindow) + + if [ $? -eq 0 ]; then WM_NAME=$(xprop -id $WINDOW_ID WM_NAME | cut -d '"' -f 2) export TERMINAL_UUID=$WM_NAME + else + export TERMINAL_UUID=$(uuidgen) fi fi echo -en "\e]2;$TERMINAL_UUID\a"