dotfiles/home/zsh/files/waypipe.zsh

19 lines
603 B
Bash
Raw Normal View History

2024-05-31 17:33:30 +02:00
if [ "$SSH_SESSION_ID" != "" ]; then
mkdir -p /tmp/ssh_sessions
echo $$ > /tmp/ssh_sessions/"$SSH_SESSION_ID"
fi
if [ "$REMOTE_PATH" != "" ]; then
if [ -d "$REMOTE_PATH" ]; then
cd "$REMOTE_PATH"
fi
elif [ "$PREVIOUS_SESSION_ID" != "" ]; then
cd "$(readlink -e /proc/$(cat /tmp/ssh_sessions/$PREVIOUS_SESSION_ID)/cwd)"
fi
function run_waypipe() {
SSH_SESSION_ID=$RANDOM
REMOTE_PATH=$(echo $(pwd) | sed "s|/home/[a-z]*|\$HOME|g")
2024-06-14 21:45:40 +02:00
SSH_SESSION_ID=$SSH_SESSION_ID waypipe -n ssh -t $1 env REMOTE_PATH=\"$REMOTE_PATH\" SSH_SESSION_ID=$SSH_SESSION_ID "zsh --login"
2024-05-31 17:33:30 +02:00
}