diff --git a/bin/clone-terminal b/bin/clone-terminal index f2cd5aa..7803e67 100755 --- a/bin/clone-terminal +++ b/bin/clone-terminal @@ -3,8 +3,12 @@ WINDOW_ID=$(xdotool getactivewindow) WM_NAME=$(xprop -id $WINDOW_ID WM_NAME | cut -d '"' -f 2) +uuid=$(uuidgen) + if [ -f $HOME/.config/terminalscwd/$WM_NAME.ssh ]; then - alacritty -e sh -c "PARENT_TERMINAL=$WM_NAME ssh $(cat $HOME/.config/terminalscwd/$WM_NAME.ssh)" + 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 - alacritty -e sh -c "PARENT_TERMINAL=$WM_NAME exec $SHELL" + cp $HOME/.config/terminalscwd/$WM_NAME.pwd $HOME/.config/terminalscwd/$uuid.pwd + alacritty --title uuid -e sh -c "PARENT_TERMINAL=$WM_NAME exec $SHELL" fi diff --git a/zsh/preserve-cwd-ssh.zsh b/zsh/preserve-cwd-ssh.zsh index d8cd39f..bc3d0ae 100644 --- a/zsh/preserve-cwd-ssh.zsh +++ b/zsh/preserve-cwd-ssh.zsh @@ -1,7 +1,15 @@ if [ "$PRESERVE_SSH_CWD" = "true" ]; then - WINDOW_ID=$(xdotool getactivewindow) - WM_NAME=$(xprop -id $WINDOW_ID WM_NAME | cut -d '"' -f 2) - export TERMINAL_UUID=$WM_NAME + if [ -z $TERMINAL_UUID ]; then + if [ -z $DISPLAY ]; then + export TERMINAL_UUID=$(uuidgen) + else + WINDOW_ID=$(xdotool getactivewindow) + WM_NAME=$(xprop -id $WINDOW_ID WM_NAME | cut -d '"' -f 2) + export TERMINAL_UUID=$WM_NAME + fi + fi + echo -en "\e]2;$TERMINAL_UUID\a" + mkdir -p $HOME/.config/terminalscwd/ cd() { builtin cd $1