forked from colonelpanic/dotfiles
15 lines
349 B
Bash
Executable File
15 lines
349 B
Bash
Executable File
#!/usr/bin/env sh
|
|
|
|
function localip {
|
|
case `uname` in
|
|
'Darwin')
|
|
ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'
|
|
;;
|
|
'Linux')
|
|
ip -4 addr | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | grep -v 127.0.0.1 | head -n 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
localip
|