Compare commits
No commits in common. "2655195f7d0edfaa1d4d6b649b73980874a7f1a8" and "39ed323d3b57c658127b6877acb5fe4526c80214" have entirely different histories.
2655195f7d
...
39ed323d3b
Binary file not shown.
Binary file not shown.
|
@ -1,32 +1,21 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
RUNNING_SSH=false
|
RUNNING_SSH=false
|
||||||
RUNNING_WAYPIPE=false
|
CHILD_PID=$(pgrep -P $1)
|
||||||
SSH_CLIENT=""
|
|
||||||
CHILD_PID=$(pgrep -P "$1")
|
|
||||||
|
|
||||||
GRAND_CHILD_PID=$(pgrep -P "$CHILD_PID")
|
[[ $(ps -p $CHILD_PID -o comm=) == "ssh" ]] && RUNNING_SSH=true
|
||||||
if [ "$GRAND_CHILD_PID" != 0 ]; then
|
|
||||||
GRAND_CHILD_NAME=$(ps -p "$GRAND_CHILD_PID" -o comm=)
|
GRAND_CHILD_PID=$(pgrep -P $CHILD_PID)
|
||||||
if [ "$GRAND_CHILD_NAME" == "ssh" ]; then
|
[[ $? == 0 ]] && [[ $(ps -p $GRAND_CHILD_PID -o comm=) == "ssh" ]] && RUNNING_SSH=true && CHILD_PID=$GRAND_CHILD_PID
|
||||||
RUNNING_SSH=true
|
|
||||||
CHILD_PID=$GRAND_CHILD_PID
|
|
||||||
SSH_CLIENT=$(ps -p "$CHILD_PID" -o args --no-headers | awk '{ print $2 }')
|
|
||||||
fi
|
|
||||||
if [ "$GRAND_CHILD_NAME" == "waypipe" ]; then
|
|
||||||
RUNNING_WAYPIPE=true
|
|
||||||
CHILD_PID=$(pgrep -P "$GRAND_CHILD_PID")
|
|
||||||
SSH_CLIENT=$(ps -p "$GRAND_CHILD_PID" -o args --no-headers | awk '{ print $3 }')
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [ $RUNNING_SSH == true ] || [ $RUNNING_WAYPIPE == true ]; then
|
if [ $RUNNING_SSH == true ]; then
|
||||||
|
CLIENT=$(ps -p $CHILD_PID -o args --no-headers | awk '{ print $2 }')
|
||||||
PORT=$(ss -tnpa | grep ssh | grep "pid=$CHILD_PID" | awk '{ print $4 }' | grep -o '[0-9]*$')
|
PORT=$(ss -tnpa | grep ssh | grep "pid=$CHILD_PID" | awk '{ print $4 }' | grep -o '[0-9]*$')
|
||||||
alacritty -e ssh "$SSH_CLIENT" -t "cd \"\$(readlink -e /proc/\$(cat /tmp/ssh_session_$PORT)/cwd)\"; zsh --login"
|
alacritty -e ssh $CLIENT -t "cd \"\$(readlink -e /proc/\$(cat /tmp/ssh_session_$PORT)/cwd)\"; zsh --login"
|
||||||
else
|
else
|
||||||
if [ "$(ps -p "$1" -o comm=)" == "alacritty" ]; then
|
if [ "$(ps -p $1 -o comm=)" == "alacritty" ]; then
|
||||||
CWD=$(readlink -e /proc/"$CHILD_PID"/cwd)
|
CWD=$(readlink -e /proc/$CHILD_PID/cwd)
|
||||||
if [ "$CWD" != "" ]; then
|
if [ "$CWD" != "" ]; then
|
||||||
alacritty --working-directory "$CWD"
|
alacritty --working-directory "$CWD"
|
||||||
else
|
else
|
||||||
|
|
10
zsh/.zshrc
10
zsh/.zshrc
|
@ -153,10 +153,6 @@ function zvm_after_init() {
|
||||||
bindkey -M emacs "^Y" find_local_files
|
bindkey -M emacs "^Y" find_local_files
|
||||||
bindkey -M vicmd "^Y" find_local_files
|
bindkey -M vicmd "^Y" find_local_files
|
||||||
bindkey -M viins "^Y" find_local_files
|
bindkey -M viins "^Y" find_local_files
|
||||||
|
|
||||||
if [ "$REMOTE_PATH" != "" ]; then
|
|
||||||
cd $REMOTE_PATH
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
|
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
|
||||||
|
@ -225,12 +221,12 @@ function o () {
|
||||||
xdg-open "$1" &!
|
xdg-open "$1" &!
|
||||||
}
|
}
|
||||||
|
|
||||||
function server() {
|
function s() {
|
||||||
waypipe ssh -t mallorea env REMOTE_PATH="$(pwd)" "zsh --login"
|
ssh server@mallorea -t "cd \"$(pwd)\" ; zsh --login"
|
||||||
}
|
}
|
||||||
|
|
||||||
function riva() {
|
function riva() {
|
||||||
waypipe ssh -t riva env REMOTE_PATH="$(pwd)" "zsh --login"
|
ssh user@riva -t "cd \"$(pwd)\" ; zsh --login"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$SSH_CLIENT" ]
|
if [ "$SSH_CLIENT" ]
|
||||||
|
|
Loading…
Reference in New Issue