Skip to content

Instantly share code, notes, and snippets.

@saul-mtz
Created January 18, 2018 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saul-mtz/9209986815dca86c73ca4d49617617db to your computer and use it in GitHub Desktop.
Save saul-mtz/9209986815dca86c73ca4d49617617db to your computer and use it in GitHub Desktop.
Custom bash prompt
# setaf colors
# https://unix.stackexchange.com/a/269085/130055
BLACK="\[$(tput setaf 0)\]"
RED="\[$(tput setaf 1)\]"
GREEN="\[$(tput setaf 2)\]"
YELLOW="\[$(tput setaf 3)\]"
BLUE="\[$(tput setaf 4)\]"
MAGENTA="\[$(tput setaf 5)\]"
CYAN="\[$(tput setaf 6)\]"
WHITE="\[$(tput setaf 7)\]"
RESET="\[$(tput sgr0)\]"
# get the ip of the current host
PS1_ip=`ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'`
# example
export PS1="[${BLUE}STAGING${RESET}][${GREEN}MongoDB${RESET}][\u@${PS1_ip} ${MAGENTA}\w${RESET}]\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment