Home

Awesome

sexy-bash-prompt Build status

Bash prompt with colors, git statuses, and git branches.

Providing a unique symbol for every combination of a dirty, unpulled, and unpushed git branch.

sexy-bash-prompt screenshot

Forked from a gist by gf3.

Do you like sexy-bash-prompt?

<!-- Derived from https://opencollective.com/sexy-bash-prompt/banner.md -->

Support us with a monthly donation and help us continue our activities or spread word on Twitter

<a href="https://opencollective.com/sexy-bash-prompt/backer/0/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/0/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/1/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/1/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/2/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/2/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/3/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/3/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/4/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/4/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/5/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/5/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/6/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/6/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/7/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/7/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/8/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/8/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/9/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/9/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/10/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/10/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/11/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/11/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/12/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/12/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/13/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/13/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/14/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/14/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/15/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/15/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/16/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/16/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/17/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/17/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/18/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/18/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/19/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/19/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/20/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/20/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/21/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/21/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/22/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/22/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/23/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/23/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/24/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/24/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/25/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/25/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/26/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/26/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/27/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/27/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/28/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/28/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/backer/29/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/backer/29/avatar.svg"></a>

Sponsors

Become a sponsor and get your logo on our README on GitHub with a link to your site. Become a sponsor

<a href="https://opencollective.com/sexy-bash-prompt/sponsor/0/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/0/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/1/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/1/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/2/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/2/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/3/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/3/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/4/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/4/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/5/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/5/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/6/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/6/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/7/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/7/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/8/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/8/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/9/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/9/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/10/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/10/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/11/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/11/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/12/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/12/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/13/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/13/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/14/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/14/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/15/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/15/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/16/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/16/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/17/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/17/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/18/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/18/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/19/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/19/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/20/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/20/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/21/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/21/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/22/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/22/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/23/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/23/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/24/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/24/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/25/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/25/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/26/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/26/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/27/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/27/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/28/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/28/avatar.svg"></a> <a href="https://opencollective.com/sexy-bash-prompt/sponsor/29/website" target="_blank"><img src="https://opencollective.com/sexy-bash-prompt/sponsor/29/avatar.svg"></a>

Installation

One line install (requires git, make):

(cd /tmp && ([[ -d sexy-bash-prompt ]] || git clone --depth 1 --config core.autocrlf=false https://github.com/twolfson/sexy-bash-prompt) && cd sexy-bash-prompt && make install) && source ~/.bashrc

My colors don't look as advertised

If you are seeing a screen like this:

Bad TERM config

Then, your TERM environment variable may never have been configured. Run the script below to prefix our prompt with a TERM setup

cat > /tmp/.bash_prompt_term <<EOF
#!/usr/bin/env bash
# Determine what type of terminal we are using for \`tput\`
if [[ \$COLORTERM = gnome-* && \$TERM = xterm ]]  && infocmp gnome-256color >/dev/null 2>&1; then export TERM=gnome-256color
elif [[ \$TERM != dumb ]] && infocmp xterm-256color >/dev/null 2>&1; then export TERM=xterm-256color
fi

EOF
chmod +x /tmp/.bash_prompt_term
cat ~/.bash_prompt >> /tmp/.bash_prompt_term
cp /tmp/.bash_prompt_term ~/.bash_prompt
rm /tmp/.bash_prompt_term

Manual install

Requirements: git, make

# Clone the repository
git clone --depth 1 --config core.autocrlf=false https://github.com/twolfson/sexy-bash-prompt
# Cloning into 'sexy-bash-prompt'...
# ...
# Resolving deltas: 100% (13/13), done.

# Go into the directory
cd sexy-bash-prompt
# Install the script
make install
# # Copying .bash_prompt to ~/.bash_prompt
# cp -f ".bash_prompt" "/home/todd/.bash_prompt"
# ./install.bash
# # twolfson/sexy-bash-prompt installation complete!

# Rerun your ~/.bashrc
source ~/.bashrc
# todd at Euclid in ~/github/sexy-bash-prompt on master
# Your PS1 should now look like this!

Configuration

Behavior

Behavior can be customized with the following environment variables:

Colors

Colors can be customized by editing .bash_prompt directly, or by setting the following environment variables:

You can set colors via tput or ANSI escape codes. For example:

# Inside your `.bashrc` or `.bash_profile`
PROMPT_USER_COLOR="$(tput bold)$(tput setaf 9)" # BOLD RED
source ~/.bash_prompt

Color overridden prompt

Symbols

Similarly, symbols can be customized with the following environment variables:

# Inside your `.bashrc` or `.bash_profile`
PROMPT_UNPUSHED_SYMBOL="↑"
source ~/.bash_prompt

Symbol overridden prompt

Compatibility

In some situations, the default symbol set can be drawn incorrectly (e.g. as diamonds). To remedy that, a simpler set of symbols can be used:

PROMPT_SYNCED_SYMBOL=""
PROMPT_DIRTY_SYNCED_SYMBOL="*"
PROMPT_UNPUSHED_SYMBOL="↑"
PROMPT_DIRTY_UNPUSHED_SYMBOL="*↑"
PROMPT_UNPULLED_SYMBOL="↓"
PROMPT_DIRTY_UNPULLED_SYMBOL="*↓"
PROMPT_UNPUSHED_UNPULLED_SYMBOL="*↑↓"
PROMPT_DIRTY_UNPUSHED_UNPULLED_SYMBOL="*↑↓"

How does it work?

bash provides a special set of variables for your prompts. PS1 is the one used by default. The install script adds a command to ~/.bashrc, a file that is run every time a new terminal opens. Inside of the new command, we run our script and set your PROMPT_COMMAND and PS1 which runs some git commands to determine its current state and outputs them as a string.

Support

Linux and Mac OSX are supported platforms.

Windows is supported to the best of my abilities. However, there have been font issues with using PuTTY.

Uninstallation

To uninstall sexy-bash-prompt, perform the following steps:

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Test via make test.

License

Copyright (c) 2013 Todd Wolfson

Licensed under the MIT license.