Created
December 3, 2013 19:13
-
-
Save miguelmota/7775690 to your computer and use it in GitHub Desktop.
Show host IP address on your bash prompt.
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
# Show host IP address on your bash prompt. | |
# | |
# Example of prompt: | |
# | |
# [email protected] : ~/Dropbox/workspace | |
# $ | |
# | |
export PS1="\n\n\[\033[0;36m\]\u@$(ifconfig | grep "inet " | grep -v 127.0.0. | awk '{print $2}')\[\033[00m\]\[\033[0;32m\] : \w\[\033[00m\]\n\[\033[00;32m\]\$\[\033[00m\] " | |
export PS2="\[\033[0;32m\]>\[\033[00m\] " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
advice
I believe that
ifconfig
has usage restrictions for non-root users.And the output will be
ifconfig: command not found
You could have the same effect using
hostname -I