Coder Social home page Coder Social logo

rapala61 / git-aware-prompt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jimeh/git-aware-prompt

0.0 1.0 0.0 274 KB

Display current Git branch name in your terminal prompt when in a Git working directory.

License: Creative Commons Zero v1.0 Universal

Shell 100.00%

git-aware-prompt's Introduction

Git Aware Prompt

Working with Git and its great branching/merging features is amazing. Constantly switching branches can be confusing though as you have to run git status to see which branch you're currently on.

The solution to this is to have your terminal prompt display the current branch. There's a number of articles available online about how to achieve this. This project is an attempt to make an easy to install/configure solution.

Overview

If you cd to a Git working directory, you will see the current Git branch name displayed in your terminal prompt. When you're not in a Git working directory, your prompt works like normal.

Git Branch in Prompt

Installation

Clone the project to a .bash folder in your home directory:

mkdir ~/.bash
cd ~/.bash
git clone git://github.com/jimeh/git-aware-prompt.git

Edit your ~/.bash_profile or ~/.profile or ~/.bashrc (for Ubuntu) and add the following to the top:

export GITAWAREPROMPT=~/.bash/git-aware-prompt
source "${GITAWAREPROMPT}/main.sh"

Configuring

Once installed, there will be new $git_branch and $git_dirty variables available to use in the PS1 environment variable, along with a number of color helper variables which you can see a list of in colors.sh.

If you want to know more about how to customize your prompt, I recommend this article: How to: Change / Setup bash custom prompt (PS1)

Suggested Prompts

Below are a few suggested prompt configurations. Simply paste the code at the end of the same file you pasted the installation code into earlier.

Mac OS X

export PS1="\u@\h \W \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "

Optionally, if you want a nice pretty prompt when using sudo -s, also add this line:

export SUDO_PS1="\[$bakred\]\u@\h\[$txtrst\] \w\$ "

Ubuntu

Standard:

export PS1="\${debian_chroot:+(\$debian_chroot)}\u@\h:\w \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "

Colorized:

export PS1="\${debian_chroot:+(\$debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "

Windows

export PS1="\[\033]0;$MSYSTEM:\w\007\033[32m\]\u@\h:\[\033[33m\w \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\033[0m\]\$ "

Updating

Assuming you followed the default installation instructions and cloned this repo to ~/.bash/git-aware-prompt:

cd ~/.bash/git-aware-prompt
git pull

Usage Tips

To view other user's tips, please check the Usage Tips wiki page. Or if you have tips of your own, feel free to add them :)

License

CC0 1.0 Universal

git-aware-prompt's People

Contributors

jimeh avatar eacousineau avatar mikesten avatar iegik avatar edwinksl avatar matt2000 avatar spoike avatar lethosor avatar olafurg avatar

Watchers

James Cloos 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.