[ssh] Cleaning up shells and ssh configurablility when not at home

This commit is contained in:
2024-08-09 10:13:03 -03:00
parent f8e270e0df
commit e7a8071ef5
6 changed files with 81 additions and 58 deletions

33
bin/.bin/onsubnet Executable file
View File

@ -0,0 +1,33 @@
#!/usr/bin/env bash
if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "" ]] ; then
printf "Usage:\n\tonsubnet [ --not ] partial-ip-address\n\n"
printf "Example:\n\tonsubnet 10.10.\n\tonsubnet --not 192.168.0.\n\n"
printf "Note:\n\tThe partial-ip-address must match starting at the first\n"
printf "\tcharacter of the ip-address, therefore the first example\n"
printf "\tabove will match 10.10.10.1 but not 110.10.10.1\n"
exit 0
fi
on=0
off=1
if [[ "$1" == "--not" ]] ; then
shift
on=1
off=0
fi
regexp="^$(sed 's/\./\\./g' <<<"$1")"
if [[ "$(uname)" == "Darwin" ]] ; then
ifconfig | grep -F 'inet ' | grep -Fv 127.0.0. | cut -d ' ' -f 2 | grep $1
else
hostname -I | tr -s " " "\012" | grep -Fv 127.0.0. | grep $1
fi
if [[ $? == 0 ]]; then
exit $on
else
exit $off
fi