From 3dd87f641d2602101a066be6f48750579d365e4a Mon Sep 17 00:00:00 2001 From: Marco Raber Date: Wed, 3 Nov 2021 13:36:19 +0100 Subject: [PATCH] try to make it work on winblows --- setup.sh | 10 +++++++--- sshin | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/setup.sh b/setup.sh index 42f931f..ac78b73 100644 --- a/setup.sh +++ b/setup.sh @@ -1,3 +1,7 @@ -mkdir ~/.local/share/sshin -[[ -e ~/.local/share/sshin/port_association ]] || cp port_association ~/.local/share/sshin/ -cp sshin ~/.local/bin || echo "Error in copying executable to ~/.local/bin" && echo "Run: sudo cp sshin /usr/bin/" +#!/bin/bash +[[ $(uname) = "Linux" ]] || echo "alias sshin=\"~/sshin/sshin\"" >> ~/.bashrc; echo "run \"source ~/.bashrc\"";exit + +PREFIX=~/.local/ +mkdir $PREFIX/share/sshin +[[ -e $PREFIX/share/sshin/port_association ]] || cp port_association $PREFIX/share/sshin/ +cp sshin $PREFIX/bin/ || echo "Error in copying executable to $PREFIX/bin" && echo "if on linux, run: sudo cp sshin /usr/bin/" diff --git a/sshin b/sshin index f69d767..01086ac 100755 --- a/sshin +++ b/sshin @@ -16,12 +16,12 @@ IP_PREFIX="192.168.1." re='^[0-9]+$' command="ssh ${1}@" shift -#[[ $1 =~ $re ]] && command="${command}192.168.1.$2" || port=$(grep $1 ~/.local/share/sshin/port_association | awk '{print $NF}') && command="${command}$1 -p $port" if [[ $1 =~ $re ]] then command="${command}192.168.1.$1" else - port=$(grep $1 ~/.local/share/sshin/port_association | awk '{print $NF}') + [[ $(uname) = "Linux" ]] && ports_file="$HOME/.local/share/sshin/port_association" || ports_file="~/sshin/port_association" + port=$(grep $1 $ports_file | awk '{print $NF}') command="${command}$1" [[ -n $port ]] && command="${command} -p $port" fi