try to make it work on winblows

This commit is contained in:
Marco Raber 2021-11-03 13:36:19 +01:00
parent 5d2b454f24
commit 3dd87f641d
2 changed files with 9 additions and 5 deletions

View File

@ -1,3 +1,7 @@
mkdir ~/.local/share/sshin #!/bin/bash
[[ -e ~/.local/share/sshin/port_association ]] || cp port_association ~/.local/share/sshin/ [[ $(uname) = "Linux" ]] || echo "alias sshin=\"~/sshin/sshin\"" >> ~/.bashrc; echo "run \"source ~/.bashrc\"";exit
cp sshin ~/.local/bin || echo "Error in copying executable to ~/.local/bin" && echo "Run: sudo cp sshin /usr/bin/"
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/"

4
sshin
View File

@ -16,12 +16,12 @@ IP_PREFIX="192.168.1."
re='^[0-9]+$' re='^[0-9]+$'
command="ssh ${1}@" command="ssh ${1}@"
shift 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 ]] if [[ $1 =~ $re ]]
then then
command="${command}192.168.1.$1" command="${command}192.168.1.$1"
else 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" command="${command}$1"
[[ -n $port ]] && command="${command} -p $port" [[ -n $port ]] && command="${command} -p $port"
fi fi