Skip to content

Commit

Permalink
Merge branch 'master' into cygwin
Browse files Browse the repository at this point in the history
Conflicts:
	README.md
  • Loading branch information
hurtstotouchfire committed Nov 29, 2014
2 parents 71db88f + cb5c10b commit 5b46361
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 10 deletions.
38 changes: 33 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
Instructions
=========
Improvements this repo provides
===============================

This assumes you've done nothing to set up git beyond registering a Github account and getting added to the org, and that you are running Mac OS or a Linux variant with a bash terminal. Windows users can make some use of these configs as well but it's not as polished yet (contributions welcome). Windows users running cygwin should branch off of the cygwin branch instead of the master branch of this repo.
In practice, most software developers use some [syntactic sugar](http://en.wikipedia.org/wiki/Syntactic_sugar) to help ease their use of git and GitHub. If you're using git on the command line (as opposed to with a GUI client), we recommend that you adopt these config files as a starting point. These files will provide you with branch information on the bash prompt as well as some convenient aliases for commands that you'll need to use on a regular basis.

Examples
------------
Standard git log shows the commit history:

![vanilla git log](images/git_log.png)

With configs, the log is more compact, color-coded, and shows the branching structure:

![git lg alias with pretty format](images/git_lg.png)

Standard bash prompt shown, must use git branch command to check current branch and git status to check for uncommitted changes:

![standard bash prompt](images/git_status.png)

With configs, bash prompt shows current branch and a red flag for uncommitted changes:

![bash prompt with git branch and status](images/git_st.png)


Installation
============

This assumes you've done nothing to set up git beyond registering a Github account and getting added to the org, and that you are running Mac OS or a Linux variant with a bash terminal. Windows users can make some use of these configs as well but it's not as polished yet (contributions welcome). Windows users running cygwin should branch off of the cygwin branch instead of the master branch of this repo. Windows users can make some use of these configs as well but it's not as polished yet (contributions welcome). Windows users running cygwin should branch off of [the cygwin branch](https://github.com/cogrhythms/git_config/tree/cygwin) instead of the master branch of this repo.


Install git
Expand All @@ -22,14 +46,16 @@ I keep all of my git repos in one directory: `~/src`, but you can put this where

```
cd ~/
git clone [email protected]:CRC-BU/git_config.git
git clone [email protected]:cogrhythms/git_config.git
```
Add prompt configuration to your bashrc
---------------------------------------
Since nearly every machine has one already, I assumed that appending would be the easiest option for everyone. If you don't have a file at `~/.bashrc`, you can just copy `append_to_bashrc` into your home directory. Just add `#!/bin/bash` on the first line of the file. The only thing to change in this text is that you have to change `dot_dir` to the directory where you cloned this repo.

After saving this, you can open a new terminal, or re-source your bashrc (run: `. ~/.bashrc`) to see the effects. This will color your prompt (colors can be configured in the script), and if you cd into the git_config directory we just cloned, you should see the branch "master" listed in the prompt.

![bash prompt for git](images/add_prompt.png)

Running git setup script
------------------------

Expand Down Expand Up @@ -67,5 +93,7 @@ In the future, any commits to this branch can be pushed using simply `git push`.

Additional Resources
=====================
- [git documentation](http://git-scm.com/docs)
- [comprehensive git documentation](http://git-scm.com/docs)
- [git command diagram / cheatsheet](http://ndpsoftware.com/git-cheatsheet.html)
- [git desktop application](http://guides.github.com/overviews/desktop/)
- [intro to branching workflows](http://guides.github.com/overviews/flow/)
13 changes: 8 additions & 5 deletions bash_prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function git_dirty {
git diff --quiet HEAD &>/dev/null
[ $? == 1 ] && echo "!"
}

# prompt components, set colors here using names from above.
# Some alternate colors are commented out as examples.
ps1_user="$BIBlue\u$NONE"
Expand All @@ -63,9 +64,11 @@ ps1_dir="$BIYellow\w$NONE"
ps1_git="$Yellow\$(parse_git_branch)$Red\$(git_dirty)$NONE"
#ps1_git="$Cyan\$(parse_git_branch)$Red\$(git_dirty)$NONE" # cyan branch name

# actually construct prompt
## Actually construct prompt
# delimiters between prompt components (like :@) are your default terminal text color, i.e. white
# renders as: user@host:dir(branch)! $
export PS1="${ps1_user}@${ps1_host}:${ps1_dir}${ps1_git} \[\$\] "
# renders as: dir(branch)! >>
#export PS1="${ps1_dir}${ps1_git} \[\>>\] "

# Option 1 renders as: user@host:dir(branch)! $
export PS1="${ps1_user}@${ps1_host}:${ps1_dir}${ps1_git} \$ "

# Option 2 renders as: dir(branch)!>>
#export PS1="${ps1_dir}${ps1_git}>> "
Binary file added images/add_prompt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/git_lg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/git_log.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/git_st.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/git_status.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5b46361

Please sign in to comment.