These are the commands I use to get my IP addresses for my machine.
To get my public IP I use the http://icanhazip.com website.
curl icanhazip.com
To get my private IP address I use the Linux hostname command to get a list of all private IP addresses, the first entry should be the private IP address to access the machine so I use the cut command to extract the first entry in the list.
hostname -I | cut -d' ' -f1
I make use of aliases in Linux and macOS and the above commands I would setup an alias for each command.
alias public-ip="curl icanhazip.com"
alias private-ip="hostname -I | cut -d' ' -f1"