dotfiles/zsh/preserve-cwd-ssh.zsh

21 lines
568 B
Bash

if [ "$PRESERVE_SSH_CWD" = "true" ]; then
mkdir -p $HOME/.config/terminalscwd/
cd() {
builtin cd $1
pwd > $HOME/.config/terminalscwd/$TERMINAL_UUID.pwd
}
if [ -f $HOME/.config/terminalscwd/$TERMINAL_UUID.pwd ]; then
cd $(cat $HOME/.config/terminalscwd/$TERMINAL_UUID.pwd)
else
cd
fi
ssh() {
echo $1 > $HOME/.config/terminalscwd/$TERMINAL_UUID.ssh
/usr/bin/ssh $@
rm $HOME/.config/terminalscwd/$TERMINAL_UUID.ssh
pwd > $HOME/.config/terminalscwd/$TERMINAL_UUID.pwd
}
fi