Git branch in Mac OSX bash prompt

I tried using the same changes for my linux boxes on my macbook air and they didn't work, so I googled around and stumbled upon using this instead:



c_cyan=`tput setaf 6`
c_red=`tput setaf 1`
c_green=`tput setaf 2`
c_sgr0=`tput sgr0`
parse_git_branch (){
    if git rev-parse --git-dir >/dev/null 2>&1
        gitver=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
        return 0
    echo -e $gitver
branch_color (){
    if git rev-parse --git-dir >/dev/null 2>&1
    if git diff --quiet 2>/dev/null >&2 
        return 0
    echo -ne $color

#Branch First
#PS1='[\[$(branch_color)\]$(parse_git_branch)\[${c_sgr0}\]] \u@\[${c_red}\]\w\[${c_sgr0}\]: '
#Branch Last
PS1=' \u@\[${c_red}\]\w\[${c_sgr0}\]: [\[$(branch_color)\]$(parse_git_branch)\[${c_sgr0}\]] '




Kohana: core, adding submodules, customization

After cloning the repository, let's add the Kohana core, a few modules and customize the installation:


git submodule add git:// modules/system

git submodule add git:// modules/database

git submodule add git:// modules/cache

git submodule add git:// modules/image

git submodule add git:// modules/pagination


2. Initialize the modules


$ git submodule init


$ git commit -m 'Added core kohana and initial submodules [cache,database,image,pagination]'
[master 1d5462d] Added core kohana and initial submodules [cache,database,image,pagination]
 6 files changed, 20 insertions(+)
 create mode 100644 .gitmodules
 create mode 160000 modules/cache
 create mode 160000 modules/database
 create mode 160000 modules/image
 create mode 160000 modules/pagination
 create mode 160000 modules/system
3. Push these changes
$ git pull origin master
From mt:~/domains/
 * branch            master     -> FETCH_HEAD
Already up-to-date.
$ git push origin master
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 663 bytes, done.
Total 4 (delta 0), reused 0 (delta 0)
To mt:~/domains/
   8bce6b1..1d5462d  master -> master
We need some more files:







$ mkdir html
$ wget -O html/index.php
–2012-07-12 00:46:18–
Resolving (…
Connecting to (||:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 3292 (3.2K) [text/plain]
Saving to: `html/index.php'
100%[=========================================================================>] 3,292       –.-K/s   in 0s
2012-07-12 00:46:19 (76.6 MB/s) – `html/index.php' saved [3292/3292]
$ wget -O html/.htaccess
–2012-07-12 00:46:47–
Resolving (…
Connecting to (||:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 517 [text/plain]
Saving to: `html/.htaccess'
100%[=========================================================================>] 517         –.-K/s   in 0s
2012-07-12 00:46:48 (24.1 MB/s) – `html/.htaccess' saved [517/517]
$ mkdir -p modules/application
$ wget -O modules/application/bootstrap.php
–2012-07-12 00:47:32–
Resolving (…
Connecting to (||:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 3612 (3.5K) [text/plain]
Saving to: `modules/application/bootstrap.php'
100%[=========================================================================>] 3,612       –.-K/s   in 0s
2012-07-12 00:47:33 (104 MB/s) – `modules/application/bootstrap.php' saved [3612/3612]
If you try accessing your site you should see an error:





Warning: require(/bootstrap.php): failed to open stream: No such file or directory in /home/httpd/domains/ on line 102


Fatal error: require(): Failed opening required '/bootstrap.php' (include_path='.:/php/library/php-redis:/usr/share/pear') in/home/httpd/domains/ on line 102




Let's adjust the environment:



















Chage a few settings:

$application = '../modules/application';

$modules = '../modules';

$system = '../modues/system';


Customize some kohana settings:




'base_url'   => '/',
'index_file' => FALSE,
'cache_dir'  => DOCROOT.'../cache'
Kohana::$log->attach(new Log_File(DOCROOT.'../logs'));









Now create the logs folder

$ mkdir logs



At this point you should have a 404 error as there's no controller:



HTTP_Exception_404 [ 404 ]: The requested URL / was not found on this server.

SYSPATH/classes/kohana/request/client/internal.php [ 87 ]

83 		try
84 		{
85 			if ( ! class_exists($prefix.$controller))
86 			{
87 				throw new HTTP_Exception_404('The requested URL :uri was not found on this server.',
88 													array(':uri' => $request->uri()));
89 			}
91 			// Load the controller using reflection
92 			$class = new ReflectionClass($prefix.$controller);
  1. SYSPATH/classes/kohana/request/client.php [ 64 ] » Kohana_Request_Client_Internal->execute_request(arguments)

  2. SYSPATH/classes/kohana/request.php [ 1138 ] » Kohana_Request_Client->execute(arguments)

  3. DOCROOT/index.php [ 109 ] » Kohana_Request->execute()





This is optional:


$ wget -O html/install.php
–2012-07-12 01:43:59–
Resolving (…
Connecting to (||:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 8411 (8.2K) [text/plain]
Saving to: `html/install.php'
100%[=========================================================================>] 8,411       –.-K/s   in 0s
2012-07-12 01:44:00 (19.5 MB/s) – `html/install.php' saved [8411/8411]
the step above download the install.php file that can be used to test your environment. There are a few things wrong in the script, but it can tell you if you env has all the bells and whisles to use Kohana



Problems you may want to fix:

The iconv extension is not loaded.

Uncomment the line

in your php.ini file and restart Apache


Kohana requires mcrypt for the Encrypt class.

Uncomment the line

in your php.ini file and restart Apache


Kohana requires GD v2 for the Image class.

Uncomment the line

in your php.ini file and restart Apache


Kohana can use the http extension for the Request_Client_External class.

Install the pecl_http extension


# pacman -Sy php-pear autoconf
# pecl install pecl_http
/usr/lib/gcc/arm-unknown-linux-gnueabi/4.7.1/cc1: error while loading shared libraries: cannot open shared object file: No such file or directory
pecl/pecl_http can optionally use PHP extension "iconv"
downloading pecl_http-1.7.4.tgz …
Starting to download pecl_http-1.7.4.tgz (174,503 bytes)
……………………………….done: 174,503 bytes
71 source files, building
running: phpize
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525


You should add "" to php.ini



Fix install.php folder checks:


<th>Cache Directory</th>
<?php if (is_dir(APPPATH) AND is_dir(DOCROOT.'../cache') AND is_writable(DOCROOT.'../cache')): ?>
<td class="pass"><?php echo DOCROOT.'../cache' ?></td>
<?php else: $failed = TRUE ?>
<td class="fail">The <code><?php echo DOCROOT.'../cache' ?></code> directory is not writable.</td>
<?php endif ?>
<th>Logs Directory</th>
<?php if (is_dir(APPPATH) AND is_dir(DOCROOT.'../logs') AND is_writable(DOCROOT.'../logs')): ?>
<td class="pass"><?php echo DOCROOT.'../logs' ?></td>
<?php else: $failed = TRUE ?>
<td class="fail">The <code><?php DOCROOT.'../logs' ?></code> directory is not writable.</td>
<?php endif ?>


Git: Prepare your repository – step 1


Here I’ll explain how you can create a new repository for your projects and use GIT for your version control needs.
For this, I’ll assume everything is already installed (git and stuff). This also assumes you’re using an Operating System and not the Vermont thing.
Replace “” with your own domain.
1. Create a base repository
$ mkdir && cd

$ git init
2. Create a standard .gitignore file
$ nano .gitignore



# Compiled source #








# Packages #


# it's better to unpack these files and commit the raw source

# git has its own built in compression methods









# Logs and databases #





# OS generated files #





3. Add and commit the file to your local repository.
$ git add .gitignore

$ git commit -m "Added standard gitignore file"
4. Prepare your local repository for transportation:
$ cd ..

$ git clone --bare

$ touch
5. Copy it to your server
6. Finish preparing your repository on the server:
$ ssh SERVER


$ git --bare update-server-info

$ cd hooks

$ mv post-update.sample post-update

$ chmod a+x post-update
From this point on, you should be able to clone your repository and start working.
Drop me a line if this does not work for you, and I'll be glad to try and help.


Git::Basic settings

Add to your home directory, and add this to your .bash_profile:


source ~/

function parse_git_dirty {
  [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"

function parse_git_branch {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"

export PS1='\h:\W$(__git_ps1 "[\[\e[0;32m\]%s\[\e[0m\]\[\e[0;33m\]$(parse_git_dirty)\[\e[0m\]]")$ '
  • IGlr