Skip to content

Instantly share code, notes, and snippets.

@surma
Created September 14, 2011 10:32
Show Gist options
  • Save surma/1216279 to your computer and use it in GitHub Desktop.
Save surma/1216279 to your computer and use it in GitHub Desktop.
Bash Prompt Code
# Colors
COLOR_WHITE='\033[1;37m'
COLOR_LIGHTGRAY='\033[0;37m'
COLOR_GRAY='\033[1;30m'
COLOR_BLACK='\033[0;30m'
COLOR_RED='\033[0;31m'
COLOR_LIGHTRED='\033[1;31m'
COLOR_GREEN='\033[0;32m'
COLOR_LIGHTGREEN='\033[1;32m'
COLOR_BROWN='\033[0;33m'
COLOR_YELLOW='\033[1;33m'
COLOR_BLUE='\033[0;34m'
COLOR_LIGHTBLUE='\033[1;34m'
COLOR_PURPLE='\033[0;35m'
COLOR_PINK='\033[1;35m'
COLOR_CYAN='\033[0;36m'
COLOR_LIGHTCYAN='\033[1;36m'
COLOR_DEFAULT='\033[0m'
# First line
# Date, Time, Bash count, number of running jobs, exit code
PS1="\n${COLOR_GRAY}--[\d \t]--[!:\! | j:\j | ?:\$?]"
# and a addition "(remote)", if the session is opened via ssh
if [ -n "${SSH_CLIENT}" ] ; then
PS1+="--${COLOR_RED}(remote)${COLOR_GRAY}"
fi
PS1+="--\n"
# second line
# full path
PS1+="${COLOR_LIGHTGRAY}\w\n"
# third line
# username, hostname and git branch
PS1+="${COLOR_LIGHTRED}(\u) ${COLOR_GREEN}\h ${COLOR_LIGHTGREEN}(\$(git branch 2>/dev/null | grep '^*' | colrm 1 2))${COLOR_DEFAULT}\n"
export PS1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment