Skip to content

Instantly share code, notes, and snippets.

@ntrepid8
Created July 25, 2016 14:05
Show Gist options
  • Save ntrepid8/243dcebeb09370d4c009bbfe1b672923 to your computer and use it in GitHub Desktop.
Save ntrepid8/243dcebeb09370d4c009bbfe1b672923 to your computer and use it in GitHub Desktop.
A bash prompt example

To get a bash promp that looks like this:

bash-prompt-example

Use this code in your .bashrc file:

source /etc/bash_completion.d/git-prompt
if [ "$color_prompt" = yes ]; then
    #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    date_ps1="\$(date +%Y-%m-%d:%H:%M:%S)"
    pwd_ps1="\$(echo \$PWD)"
    PS1="\[\e[01;35m\]$date_ps1 $pwd_ps1\n\[\e[01;34m\][aws=\$AWS_DEFAULT_PROFILE][region=\$AWS_REGION]\$(__git_ps1)\[\e[0m\]\[\e[01;32m\] \n\$ "
    trap 'echo -ne "\e[0m"' DEBUG
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

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