Created
April 15, 2012 02:17
-
-
Save rafbm/2389381 to your computer and use it in GitHub Desktop.
Copy your local IP address from the command line (OS X)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I often need this IP for testing local websites in VirtualBox | |
echo -n `ifconfig | grep -Po "(?<=inet )\d*\.\d*\.\d*\.\d*(?=.*broadcast)"` | pbcopy | |
# Less Unix-y, somewhat more readable version | |
ifconfig | ruby -e "print STDIN.read.match(/inet (\d*\.\d*\.\d*\.\d*).*broadcast/)[1]" | pbcopy | |
# I use it like this in my .zshrc | |
alias ip='echo -n `ifconfig | grep -Po "(?<=inet )\d*\.\d*\.\d*\.\d*(?=.*broadcast)"` | pbcopy' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment