diff --git a/zsh/preserve-cwd-ssh.zsh b/zsh/preserve-cwd-ssh.zsh index 7169955..54d94e2 100644 --- a/zsh/preserve-cwd-ssh.zsh +++ b/zsh/preserve-cwd-ssh.zsh @@ -7,10 +7,21 @@ if [ "$PRESERVE_SSH_CWD" = "true" ]; then cd() { if [ -z "$1" ]; then directory=$HOME + elif [[ "$1" == "-P" ]] && [ -z $2 ]; then + directory="$HOME" + option="$1" + elif [[ "$1" == "-P" ]]; then + directory="$2" + option="$1" else directory="$1" fi - builtin cd "$directory" + + if [ -z "$option" ]; then + builtin cd "$directory" + else + builtin cd "$option" "$directory" + fi pwd > $HOME/.config/terminalscwd/$TERMINAL_UUID.cwd }