From 1facb0079a167f0430b00f58a682ba4bc521ba34 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Mon, 24 Jun 2024 14:09:50 +0200 Subject: [PATCH] Prevent bug when PARENT_TERMINAL is empty --- zsh/preserve-cwd-ssh.zsh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/zsh/preserve-cwd-ssh.zsh b/zsh/preserve-cwd-ssh.zsh index 3932e14..0542659 100644 --- a/zsh/preserve-cwd-ssh.zsh +++ b/zsh/preserve-cwd-ssh.zsh @@ -25,12 +25,15 @@ if [ "$PRESERVE_SSH_CWD" = "true" ]; then fi # Copy state for new terminal - if [ -f $HOME/.config/terminalscwd/$PARENT_TERMINAL.cwd ]; then - cp $HOME/.config/terminalscwd/$PARENT_TERMINAL.cwd $HOME/.config/terminalscwd/$TERMINAL_UUID.cwd - fi + if [ ! -z $PARENT_TERMINAL ]; then + if [ -f $HOME/.config/terminalscwd/$PARENT_TERMINAL.cwd ]; then + cp $HOME/.config/terminalscwd/$PARENT_TERMINAL.cwd $HOME/.config/terminalscwd/$TERMINAL_UUID.cwd + fi - if [ -f $HOME/.config/terminalscwd/$PARENT_TERMINAL.ssh ]; then - cp $HOME/.config/terminalscwd/$PARENT_TERMINAL.ssh $HOME/.config/terminalscwd/$TERMINAL_UUID.ssh + if [ -f $HOME/.config/terminalscwd/$PARENT_TERMINAL.ssh ]; then + echo $HOME/.config/terminalscwd/$PARENT_TERMINAL.ssh $HOME/.config/terminalscwd/$TERMINAL_UUID.ssh + cp $HOME/.config/terminalscwd/$PARENT_TERMINAL.ssh $HOME/.config/terminalscwd/$TERMINAL_UUID.ssh + fi fi # When we're done, delete the uuid files