Merge branch 'master' into laptop

This commit is contained in:
Thomas Avé 2023-09-17 20:52:15 +02:00
commit 209c9fe5c8
1 changed files with 13 additions and 0 deletions

View File

@ -1,6 +1,19 @@
#!/bin/bash
CHILD_PID=$(pgrep -P $1)
GRAND_CHILD_PID=$(pgrep -P $CHILD_PID)
if [ $? == 0 ]
then
PROCESS=$(ps -p $GRAND_CHILD_PID -o comm=)
COMMAND=$(ps -p $GRAND_CHILD_PID -o args --no-headers)
if [ $PROCESS == "ssh" ]
then
PORT=$(ss -tnpa | grep ssh | grep "pid=$GRAND_CHILD_PID" | awk '{ print $4 }' | grep -o '[0-9]*$')
alacritty -e $COMMAND -t "cd \$(readlink -e /proc/\$(cat /tmp/ssh_session_$PORT)/cwd); zsh --login"
exit 0
fi
fi
pushd "/proc/$CHILD_PID/cwd"
SHELL_CWD=$(pwd -P)