From 3d14d339b4cee28d9c1b2f3cd65851f4f3b3d95c Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Thu, 15 Dec 2022 22:55:56 -0500 Subject: [PATCH] add: fish config file for linux and npiperelay --- .config/fish/config-linux.fish | 6 ++++++ .config/fish/config-npiperelay.fish | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 .config/fish/config-linux.fish create mode 100644 .config/fish/config-npiperelay.fish diff --git a/.config/fish/config-linux.fish b/.config/fish/config-linux.fish new file mode 100644 index 0000000..b6e7a02 --- /dev/null +++ b/.config/fish/config-linux.fish @@ -0,0 +1,6 @@ +#x-server +set -g DISPLAY $(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0 + +if test -x (command -v npiperelay.exe) + source (dirname (status --current-file))/config-npiperelay.fish +end diff --git a/.config/fish/config-npiperelay.fish b/.config/fish/config-npiperelay.fish new file mode 100644 index 0000000..5622f50 --- /dev/null +++ b/.config/fish/config-npiperelay.fish @@ -0,0 +1,20 @@ +# Configure ssh forwarding +set -x SSH_AUTH_SOCK $HOME/.ssh/agent.sock + +# use square brackets to generate a regex match for the process we want but that doesn't match the grep command running it! +set ALREADY_RUNNING (ps -aux | grep -q "[n]piperelay.exe -ei -s //./pipe/openssh-ssh-agent"; echo $status) + +if [ $ALREADY_RUNNING -ne 0 ] + if [ -S $SSH_AUTH_SOCK ] + # not expecting the socket to exist as the forwarding command isn't running (http://www.tldp.org/LDP/abs/html/fto.html) + # echo "removing previous socket..." + rm $SSH_AUTH_SOCK + end + + # echo "Starting SSH-Agent relay..." + # setsid to force new session to keep running + # set socat to listen on $SSH_AUTH_SOCK and forward to npiperelay which then forwards to openssh-ssh-agent on windows + begin + setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork >/dev/null 2>&1 & + end +end