Create Script ipadress.sh:
#!/bin/bash
# Print the IP address with hostname
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
else
printf "No Network\n"
fi
Edit (or create) ~/.bash_aliases with:
alias checknet='sh /home/pi/ipadress.sh'
Exit your session and log in again and test it:
pi@zepir:~ $ checknet
My IP address is 10.10.10.2
Link: https://raspberrypi.stackexchange.com/questions/4284/how-to-run-a-command-with-alias