• Stars
    star
    1,116
  • Rank 40,094 (Top 0.9 %)
  • Language
    Shell
  • License
    MIT License
  • Created almost 11 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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?

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

Sponsors

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

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:

  • PROMPT_SHOW_ERROR_ONCE - If enabled (default), then will only show error color once per command execution
    • bash persists a non-zero exit code across missing commands (e.g. comment line only, keyboard interrupt, empty command)
    • Setting this to 1 (default) means show error status once, 0 means always show same error status until a new command is executed

Colors

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

  • PROMPT_USER_COLOR - Color for username (e.g. todd)
  • PROMPT_PREPOSITION_COLOR - Color for 'at', 'in', 'on'
  • PROMPT_DEVICE_COLOR - Color for machine name (e.g. Euclid)
  • PROMPT_DIR_COLOR - Color for directory (e.g. ~/github/sexy-bash-prompt)
  • PROMPT_GIT_STATUS_COLOR - Color for git branch and symbol (e.g. master)
  • PROMPT_GIT_PROGRESS_COLOR - Color for in progress git actions (e.g. [merge])
  • PROMPT_SYMBOL_COLOR - Color for prompt symbol by default or on success (e.g. $)
  • PROMPT_SYMBOL_ERROR_COLOR - Color for prompt symbol on error (e.g. $)

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:

  • PROMPT_SYNCED_SYMBOL - Symbol for clean and synced branch (e.g. empty string)
  • PROMPT_DIRTY_SYNCED_SYMBOL - Symbol for dirty and synced branch (e.g. *)
  • PROMPT_UNPUSHED_SYMBOL - Symbol for unpushed branch (e.g. â–³)
  • PROMPT_DIRTY_UNPUSHED_SYMBOL - Symbol for dirty and unpushed branch (e.g. â–²)
  • PROMPT_UNPULLED_SYMBOL - Symbol for unpulled branch (e.g. â–½)
  • PROMPT_DIRTY_UNPULLED_SYMBOL - Symbol for dirty and unpulled branch (e.g. â–¼)
  • PROMPT_UNPUSHED_UNPULLED_SYMBOL - Symbol for unpushed and unpulled branch (e.g. ⬡)
  • PROMPT_DIRTY_UNPUSHED_UNPULLED_SYMBOL - Symbol for dirty, unpushed, and unpulled branch (e.g. ⬢)
  • PROMPT_SYMBOL - Symbol given after each prompt (e.g. $)
    • By default, this is $ for normal users and # for root
# 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:

  • Remove . ~/.bash_prompt from ~/.bashrc
  • Delete ~/.bash_prompt (e.g. rm ~/.bash_prompt)
  • During installation, we may have added a . ~/.bashrc invocation to ~/.bash_profile, ~/.bash_login, or ~/.profile
    • Feel free to remove this if it's no longer necessary

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.

More Repositories

1

grunt-spritesmith

Grunt task for converting a set of images into a spritesheet and corresponding CSS variables
JavaScript
1,140
star
2

gulp.spritesmith

Convert a set of images into a spritesheet and CSS variables via gulp
JavaScript
1,080
star
3

spritesmith

Utility that takes sprites and converts them into a stylesheet and its coordinates
JavaScript
898
star
4

google-music-electron

Desktop app for Google Music on top of Electron
JavaScript
265
star
5

restructuredtext-lint

reStructuredText linter
Python
162
star
6

layout

Organize and layout items based on various algorithms
JavaScript
112
star
7

spritesheet-templates

Convert spritesheet data into CSS or CSS pre-processor data
JavaScript
106
star
8

sublime-hooks

Run Sublime commands on common event hooks (e.g. on_new, on_post_save).
Python
96
star
9

grunt-zip

Zip and unzip files via a grunt plugin
JavaScript
89
star
10

File-Watcher

Watch multiple files for changes
JavaScript
88
star
11

gif-encoder

Streaming GIF encoder
JavaScript
82
star
12

grunt-curl

Download files from the internet via grunt.
JavaScript
73
star
13

FindPlusPlus

Find code quickly in Sublime Text.
Python
62
star
14

sublime-files

An extracted backup of Sublime Text's files
Python
60
star
15

karma-electron

Karma launcher and preprocessor for Electron
JavaScript
59
star
16

google-music.js

Browser-side JS library for controlling Google Music
JavaScript
47
star
17

iframe2image

Convert an iframe to an image
JavaScript
47
star
18

grunt-jsmin-sourcemap

Grunt task for JSMin with sourcemap
JavaScript
44
star
19

foundry

Release manager for npm, bower, component, PyPI, git tags, and any command you want
JavaScript
41
star
20

computedStyle

Cross-browser currentStyle/getComputedStyle implementation
JavaScript
40
star
21

css-validator

Validate CSS via W3C's service
JavaScript
40
star
22

grunt-fontsmith

**DEPRECATED** Grunt plugin for composing SVGs into multiple fonts, a character mapping, and CSS variables
JavaScript
38
star
23

jojo

the 10 second blog-engine for hackers (in javascript)
JavaScript
36
star
24

twolfson.com-scripts

Scripts used for bootstrapping and deploying services for twolfson.com and its subdomains
Ruby
32
star
25

reverse-mustache

Reverse templating library for mustache, generating variables from a template's output
JavaScript
29
star
26

gifsockets

Stream never-ending animated GIFs
JavaScript
28
star
27

line-height

Calculate line-height of an HTML element (IE6 compatible)
JavaScript
27
star
28

commander-completion

Shell completion for commander.js
JavaScript
26
star
29

bookmarks

Webpage representing a collection of bookmarks
JavaScript
26
star
30

pixelsmith

Node based engine for `spritesmith` built of top of `get-pixels` and `save-pixels`.
JavaScript
23
star
31

sublime-plugin-tests

Testing framework for Sublime Text plugins
Python
22
star
32

source-map-index-generator

Generate source-maps from index mappings.
JavaScript
21
star
33

icomoon-phantomjs

**DEPRECATED** IcoMoon driver written in PhantomJS
JavaScript
20
star
34

sublime-edit-command-palette

Add/edit commands for your Command Palette
Python
19
star
35

css-controls

Cross-browser stylesheet creation and css rule creation/deletion (includes IE6 support)
JavaScript
18
star
36

dotfiles

A collection of my dotfiles (e.g. `.config`, `.bashrc`)
Shell
15
star
37

vagrant-lime

Vagrantfile for limetext/lime
14
star
38

grunt-html-prettyprinter

Grunt task that beautifies your HTML
JavaScript
13
star
39

twolfson.com

Repository for twolfson.com
JavaScript
13
star
40

function-to-string

Extract parameters and body of a function into strings
JavaScript
12
star
41

sublime-request

Make HTTP requests from Sublime Text
Python
11
star
42

ecma-variable-scope

AST utility to collect scope info for variables
JavaScript
11
star
43

nine-track

Record and playback HTTP requests
JavaScript
10
star
44

node-jsmin-sourcemap

JSMin with sourcemaps!
JavaScript
10
star
45

firefox-bookmarks

Extract information from your Firefox bookmarks
JavaScript
10
star
46

gmsmith

GM engine for spritesmith
JavaScript
10
star
47

record-a-cast

Select and record a portion of your desktop
JavaScript
9
star
48

shenzhen-io-solutions

@twolfson's solutions for Shenzhen I/O
9
star
49

katex-screenshot

Convert KaTeX to images via screenshots
JavaScript
9
star
50

google-music-webkit

Google Music desktop client via nw.js
JavaScript
9
star
51

completion

Completion library for CLI commands
JavaScript
9
star
52

fontsmith

**DEPRECATED** Collect SVGs into multiple fonts and a character code mapping
JavaScript
9
star
53

victorious-git

Play fanfare after triumphing over git conflicts
Shell
8
star
54

paypal-github-button

GitHub styled button for PayPal
JavaScript
8
star
55

spritesmith-engine-test

Common test suite for spritesmith engines
JavaScript
7
star
56

pinboard.js

Library for talking to the Pinboard API
JavaScript
7
star
57

cli-presentation

Give presentations from your terminal
JavaScript
7
star
58

esformatter-var-each

Esformatter plugin that converts comma `var` statements into separate `var` statements
JavaScript
6
star
59

esformatter-phonetic

Esformatter plugin that renames variables and functions to pronounceable names
JavaScript
6
star
60

git-sqwish

Squash commits without repetitive conflicts
Shell
6
star
61

listen-spawn

Run commands in your terminal via HTTP.
JavaScript
6
star
62

Style-Tile-SVG

Style tile template in SVG format
6
star
63

sublime-info

Gather information about Sublime Text
Python
5
star
64

develop-faster-presentation

Presentation on removing the tedium from creating, developing, and publishing repos.
JavaScript
5
star
65

whatsizeismybrowser

Determine the dimensions of your browser
JavaScript
5
star
66

canvassmith

node-canvas engine for spritesmith
JavaScript
5
star
67

json2fontcss

Converter from JSON to font variables for CSS
JavaScript
5
star
68

vagrant-nodebugme

Vagrant for `nodebugme`
Shell
4
star
69

grunt-install-init

Install a grunt init template
JavaScript
4
star
70

pngsmith

png engine for spritesmith
JavaScript
4
star
71

Facebook-Scraper

Javascript project to scrape friend data from Facebook's mobile site
JavaScript
4
star
72

spritesmith-engine-spec

Specification for spritesmith engines
Shell
4
star
73

phantomjssmith

PhantomJS engine for spritesmith
JavaScript
4
star
74

winfiles

Dotfiles variant for Windows
Shell
4
star
75

sublime-snippet-destroyer

Destroy all Sublime Text completions and snippets
Python
4
star
76

Resource-Collector

Collect the urls of all relative resources from a webpage and return them to a callback.
JavaScript
4
star
77

fix-travis-ci

Repair annoying repetitive issues with Travis CI
Shell
4
star
78

sublime-plugin-tests-base

Base layer for testing and assertion frameworks against Sublime Text
Python
3
star
79

single-child

Spawn a single child process which kills itself on restart.
JavaScript
3
star
80

Mason.js

HTML power tool that generates robust UI elements near-transparently
JavaScript
3
star
81

json-content-demux

Break up JSON from content in a JSON-first file
JavaScript
3
star
82

phantomjsify

Browserify transform to fallback node.js basics in PhantomJS
JavaScript
3
star
83

kaleidoscope

View multiple pages at the same time
JavaScript
3
star
84

controlpad

WindowPad functionality for Linux.
JavaScript
3
star
85

CSS-Off--2011-

Website created for the 2011 CSS Off by Unmatched Style
JavaScript
3
star
86

grunt-init-init

Create a grunt template from any grunt template
JavaScript
3
star
87

vagrant-gitlist

Plug and play Vagrantfile for GitList
3
star
88

arduino-playground

Playground environment for one-offs as I learn Arduino and electronics in general
C++
2
star
89

sublime-js-var-shortcuts

Insert and delete shortcuts for JavaScript variables in Sublime Text
Python
2
star
90

Facebook-Auto-Subscriber

Automatically change your friend subscriptions to one standard format
JavaScript
2
star
91

multi-image-mergetool

Resolve multiple image conflicts at the same time
JavaScript
2
star
92

sublime-installer

Shell script to install Sublime Text 2 and 3
Shell
2
star
93

ecma-scopes

Listing of block and lexical scope names for ECMAScript AST
JavaScript
2
star
94

object-fusion2

Another way to combine outline and content into an object.
JavaScript
2
star
95

gifsockets-middleware

Set of HTTP middlewares for gifsockets
JavaScript
2
star
96

phantomjs-pixel-server

PhantomJS server that converts canvas actions into pixels
JavaScript
2
star
97

foundry-release-git

git release library for foundry
JavaScript
2
star
98

trunkata

Truncation utility which preserves HTML content and can truncate by lines.
JavaScript
2
star
99

IndexedDB-Editor

Indexed DB Editor for MDN Dev Derby December 2011
2
star
100

lantern-wall

Documentation for a glowing lantern wall
C++
2
star