Add 'myip.sh'

This commit is contained in:
2023-05-01 02:53:07 +02:00
parent 9ead01145d
commit 3f621635fb

17
myip.sh Normal file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
function get_ip {
ip a show $1 | grep -m 1 inet | awk '{print $2}' | cut -d / -f 1
}
INTERFACES=$(ip a show | grep -E "^[0-9]:" | cut -d ' ' -f 2 | cut -d : -f 1)
for ni in $INTERFACES
do
if [[ $ni != "lo" ]]; then
IP="$(get_ip $ni)"
if [[ ! -z $IP ]]; then
echo -n " #[fg=#${COLOR_ACCENT}]$ni #[fg=white]$IP"
fi
fi
done