Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Created December 3, 2013 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save miguelmota/7775690 to your computer and use it in GitHub Desktop.
Save miguelmota/7775690 to your computer and use it in GitHub Desktop.
Show host IP address on your bash prompt.
# Show host IP address on your bash prompt.
#
# Example of prompt:
#
# moogs@192.168.1.100 : ~/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\] "
@rdimitrovbg
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment