ifconfig on a Mac prints a wall of text for a dozen interfaces. When you just want your address on the local network, there’s a shorter way.
Ask ipconfig for the address of one interface:
ipconfig getifaddr en0
The answer is one line with an IPv4 address and nothing else. That makes it easy to use in a script or to copy into another device, for example when you want to open a dev server on your phone or type the Mac’s address into an app on the TV.
The man page says it prints the IP address for the first network service on that interface, and that the output is empty if no service is configured or active there. I find that empty result useful in itself: a script can check whether you’re on the cable or on Wi-Fi.
ipconfig getifaddr en5 || echo "not on the cable"
The command exits with an error when there’s no address, which is why the || part works.
The catch is the device name. en0 is usually Wi-Fi on a MacBook, but an Ethernet adapter or dock gets another name, and desktop Macs can differ. Run networksetup -listallhardwareports once to see which device is which. And this is your local address; the address websites see is the public one from your router.
Further reading: ipconfig.8 man page