Skip to content

Instantly share code, notes, and snippets.

@earvinpiamonte
Created July 24, 2025 14:47
Show Gist options
  • Save earvinpiamonte/ae718316e8469bb9d03c550e574efbd5 to your computer and use it in GitHub Desktop.
Save earvinpiamonte/ae718316e8469bb9d03c550e574efbd5 to your computer and use it in GitHub Desktop.

Revisions

  1. earvinpiamonte created this gist Jul 24, 2025.
    17 changes: 17 additions & 0 deletions .ip_alias.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    ip() {
    case "$1" in
    public)
    echo "$(curl -s https://api.ipify.org | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}')"
    ;;
    internal)
    ipconfig getifaddr $(route get default 2>/dev/null | awk '/interface: / {print $2}')
    ;;
    private)
    ifconfig | awk '/^(utun|ppp)/ {iface=$1} iface && $1 == "inet" && $2 ~ /^10\./ {print $2; exit}'
    ;;
    *)
    echo "Usage: ip [public|internal|private]"
    return 1
    ;;
    esac
    }