Skip to content

Instantly share code, notes, and snippets.

@xtetsuji
Last active December 17, 2022 04:33
Show Gist options
  • Save xtetsuji/366a181a0a3b09687fe90fc49ac8dd5b to your computer and use it in GitHub Desktop.
Save xtetsuji/366a181a0a3b09687fe90fc49ac8dd5b to your computer and use it in GitHub Desktop.
print default gateway. and open browser if argument has `-w`
#!/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