GithubHelp home page GithubHelp logo

cristianogregnanin / sexy-bash-prompt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from twolfson/sexy-bash-prompt

0.0 3.0 0.0 1.51 MB

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

License: MIT License

sexy-bash-prompt's Introduction

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.

Installation

One line install:

(cd /tmp && git clone --depth 1 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

$ # Clone the repository
$ git clone --depth 1 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 --force .bash_prompt ~/.bash_prompt
# Adding ~/.bash_prompt to ~/.bashrc
echo ". ~/.bash_prompt" >> ~/.bashrc
# 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

The styles 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 (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

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 PS1 which runs some git commands to determine its current state and outputs them as a string.

Donating

Support this project and others by twolfson via gittip.

Support via Gittip

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.

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.

sexy-bash-prompt's People

Contributors

twolfson avatar rpdelaney avatar gf3 avatar

Watchers

James Cloos avatar Cristiano avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.