Created
January 18, 2018 07:18
-
-
Save saul-mtz/9209986815dca86c73ca4d49617617db to your computer and use it in GitHub Desktop.
Custom 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
# 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