Permalink
Browse files

Move .gitfiles/ignore to ~/.gitignore, switch to shell version of git…

…-cwd-info
  • Loading branch information...
1 parent a21de0d commit b8c821cbb97fd6bc71979ce70884a674b3b49901 @j16r committed Apr 10, 2012
View
@@ -5,7 +5,7 @@
user = GITHUB_USER
token = GITHUB_TOKEN
[core]
- excludesfile = ~/.gitfiles/ignore
+ excludesfile = ~/.gitignore
# Tabs appear as two spaces
pager = less -FXRS -x2
[alias]
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+# Emits Git metadata for use in a Zsh prompt.
+#
+# Based on Geoffrey Grosenbach's modified version of:
+# https://github.com/benhoskings/dot-files/blob/master/files/bin/git_cwd_info
+#
+# Rewritten as shell script simply for speed
+
+GIT_REPO_PATH=`git rev-parse --git-dir 2>/dev/null`
+
+if [[ $GIT_REPO_PATH != '' && $GIT_REPO_PATH != '~' && $GIT_REPO_PATH != "$HOME/.git" ]]; then
+
+ GIT_BRANCH=`git symbolic-ref -q HEAD | sed 's/refs\/heads\///'`
+ GIT_COMMIT_ID=`git rev-parse --short HEAD 2>/dev/null`
+
+ GIT_MODE=""
+ if [[ -e "$GIT_REPO_PATH/BISECT_LOG" ]]; then
+ GIT_MODE=" +bisect"
+ elif [[ -e "$GIT_REPO_PATH/MERGE_HEAD" ]]; then
+ GIT_MODE=" +merge"
+ elif [[ -e "$GIT_REPO_PATH/rebase" || -e "$GIT_REPO_PATH/rebase-apply" || -e "$GIT_REPO_PATH/rebase-merge" || -e "$GIT_REPO_PATH/../.dotest" ]]; then
+ GIT_MODE=" +rebase"
+ fi
+
+ GIT_DIRTY=""
+ if [[ "$GIT_REPO_PATH" != '.' && `git ls-files -m` != "" ]]; then
+ GIT_DIRTY=" %{%}✗%{%}"
+ fi
+
+ echo " %{%}$GIT_BRANCH %{%}$GIT_COMMIT_ID%{%}$GIT_MODE$GIT_DIRTY"
+fi
@@ -1,51 +0,0 @@
-#!/usr/bin/env ruby
-# -*- coding: utf-8 -*-
-
-# Emits Git metadata for use in a Zsh prompt.
-#
-# AUTHOR:
-# Ben Hoskings
-# https://github.com/benhoskings/dot-files/blob/master/files/bin/git_cwd_info
-#
-# MODIFIED:
-# Geoffrey Grosenbach http://peepcode.com
-
-# The methods that get called more than once are memoized.
-
-def git_repo_path
- @git_repo_path ||= `git rev-parse --git-dir 2>/dev/null`.strip
-end
-
-def in_git_repo
- !git_repo_path.empty? &&
- git_repo_path != '~' &&
- git_repo_path != "#{ENV['HOME']}/.git"
-end
-
-def git_parse_branch
- @git_parse_branch ||= `git symbolic-ref -q HEAD`.match(%{refs/heads/(.*)$})[1]
-rescue
- ''
-end
-
-def git_head_commit_id
- `git rev-parse --short HEAD 2>/dev/null`.strip
-end
-
-def git_cwd_dirty
- " %{\e[90m%}✗%{\e[0m%}" unless git_repo_path == '.' || `git ls-files -m`.strip.empty?
-end
-
-def rebasing_etc
- if File.exists?(File.join(git_repo_path, 'BISECT_LOG'))
- "+bisect"
- elsif File.exists?(File.join(git_repo_path, 'MERGE_HEAD'))
- "+merge"
- elsif %w[rebase rebase-apply rebase-merge ../.dotest].any? {|d| File.exists?(File.join(git_repo_path, d)) }
- "+rebase"
- end
-end
-
-if in_git_repo
- print " %{\e[90m%}#{git_parse_branch} %{\e[37m%}#{git_head_commit_id}%{\e[0m%}#{rebasing_etc}#{git_cwd_dirty}"
-end
File renamed without changes.

0 comments on commit b8c821c

Please sign in to comment.