Created
June 15, 2012 02:28
-
-
Save mkelley33/2934381 to your computer and use it in GitHub Desktop.
Copy computer's IP address to clipboard
This file contains 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
# When testing a rails website on my local development machine, I found my | |
# Parallel's VM wouldn't load 0.0.0.0:3000, 127.0.0.1, or localhost:3000. | |
# | |
# So I tried using my computers IP address and voila. I thought I'd hone | |
# my bash chops a little and extract the IP address with the port number | |
# concatenated to it. This command puts that on the clipboard so I can just | |
# paste it into IE so I could browser test. | |
# | |
# NOTE: the pbcopy command is Mac specific. | |
# | |
# In my .profile: | |
alias cpip="ifconfig \ | |
| grep en1 -A1 \ | |
| grep -Eo 'inet\ [1-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' \ | |
| cut -c 6- \ | |
| xargs -I {} echo {}:'3000' \ | |
| pbcopy" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the tips, code, and explanation. Learning more about bash scripting is at the top of my list so this is much appreciated!