Last active
December 17, 2022 04:33
-
-
Save xtetsuji/366a181a0a3b09687fe90fc49ac8dd5b to your computer and use it in GitHub Desktop.
print default gateway. and open browser if argument has `-w`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
browser=open | |
default_gw=$( route -n get 0.0.0.0 | grep gateway | sed -e 's/.*: //' ) | |
if [ "_${1:-}" = "_-w" ] ; then | |
"$browser" "http://$default_gw/" | |
fi | |
echo "$default_gw" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment