bash add IP in PWD to variable for easy reference

Add to .bashrc:

export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND ;} ip=\$( echo \$PWD | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' ) "

Now if you browse to/in a directory which has an ipv4 ip, the IP will be stored in the $ip variable.