Giter VIP home page Giter VIP logo

bash-git-prompt's Introduction

bash-git-prompt

What/Why?

My own variation on the bash git prompt. I took much of the ideas from magicmonty/bash-git-prompt. I wanted something simpler in functionality and implementation. Created some functions to organize. Here are some sample prompts:

parrt prompt

It shows the branch you are on and whether it is clean or not with a green or yellow branch name (clean means no staged or modified files).

It shows upward arrow if you are ahead and downward arrow if you are behind or both. Took me forever to figure out that you need to git fetch before computing "behind" works. :( Now correctly handles a fetch of remote for each repo every 30 minutes. Stores a small file in repo root: .fetch_time_cache.

Install

You can put file parrt-prompt.py anywhere but that incantation below assumes it's in the ~/.bash directory.

Add the following incantation to your .bash_profile or .bashrc, if you are using that file.

PROMPT_COMMAND='PS1="`python ~/.bash/parrt-prompt.py`"'

If you want to get fancy, the following variation will also set the title of the window (on OS X at least) to the current working directory.

PROMPT_COMMAND='echo -n -e "\033]0;`pwd`\007"; PS1="`python ~/.bash/parrt-prompt.py`"'

Misc

You might want to update the bash that sits on OS X by default:

$ bash --version
GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)
Copyright (C) 2007 Free Software Foundation, Inc.
$ brew install bash
...
$ bash # launch new shell in this window or open new tab/window.
$ bash --version
GNU bash, version 4.3.18(1)-release (x86_64-apple-darwin13.3.0)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$

bash-git-prompt's People

Contributors

parrt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

recoder

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.