Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: kyriacos/dotfiles
base: 46b12ee8b2
...
head fork: kyriacos/dotfiles
compare: c0e65d9d76
  • 11 commits
  • 10 files changed
  • 0 commit comments
  • 1 contributor
4 git_diff_wrapper
View
@@ -0,0 +1,4 @@
+#!/bin/sh
+function git_diff_wrapper() {
+ vimdiff "$3" "$4"
+}
74 gitconfig
View
@@ -1,41 +1,53 @@
# Copy this file or single lines to ~/.gitconfig
+[github]
+ username = kyriacos
[core]
-excludesfile = /Users/Kyriacos/.gitignore
+ excludesfile = /Users/Kyriacos/.gitignore
+[heroku]
+ account = personal
[alias]
-co = checkout
-# Other useful aliases:
-unstage = reset HEAD
-staged = diff --cached
-unstaged = diff
-current-branch = !git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||'
-# Usage: git track origin/feature-123-login-form
-track = checkout -t
+ co = checkout
+ # Other useful aliases:
+ unstage = reset HEAD
+ staged = diff --cached
+ unstaged = diff
+ current-branch = !git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||'
+ # Usage: git track origin/feature-123-login-form
+ track = checkout -t
-# logs
-# Log display from screencast, with train tracks.
-lo = log --graph --pretty=format':%C(yellow)%h%Cblue%d%Creset %s %C(white) %an, %ar%Creset'
-# Alternate log display from Scott Chacon
-lol = log --pretty=oneline --abbrev-commit --graph --decorate
-# gb
-head = !git l -1
-h = !git head
-hp = "!source ~/.githelpers && show_git_head"
-r = !git l -30
-ra = !git r --all
-l = "!source ~/.githelpers && pretty_git_log"
-la = !git l --all
+ # logs
+ # Log display from screencast, with train tracks.
+ lo = log --graph --pretty=format':%C(yellow)%h%Cblue%d%Creset %s %C(white) %an, %ar%Creset'
+ # Alternate log display from Scott Chacon
+ lol = log --pretty=oneline --abbrev-commit --graph --decorate
+ # gb
+ head = !git l -1
+ h = !git head
+ hp = "!source ~/.githelpers && show_git_head"
+ r = !git l -30
+ ra = !git r --all
+ l = "!source ~/.githelpers && pretty_git_log"
+ la = !git l --all
+ d = difftool
[apply]
-whitespace = warn
+ whitespace = warn
[color]
-diff = auto
-status = auto
-branch = auto
-ui = true
+ diff = auto
+ status = auto
+ branch = auto
+ ui = true
[help]
-autocorrect = 1
+ autocorrect = 1
[status]
-submodule = 1
+ submodule = 1
[push]
-# Only push branches that have been set up to track a remote branch.
-default = current
+ # Only push branches that have been set up to track a remote branch.
+ default = current
+[merge]
+ tool = vimdiff
+ stat = true # show a diffstat at the end of a merge
+[diff]
+ tool = vimdiff
+[difftool]
+ prompt = false
2  gitignore
View
@@ -1,7 +1,5 @@
/.bundle
-.Gemfile
/.rbenv-version
-/Gemfile.lock
vendor/bundle
tags
gems.tags
20 vimrc
View
@@ -21,13 +21,8 @@ filetype plugin indent on " Turn on file type detection.
" Solarized theme
set t_Co=256
let g:solarized_termcolors=256
-"let g:solarized_contrast="high"
set background=light
color solarized
-"set background=dark
-"colorscheme mustang
-"colorscheme molokai
-"colorscheme ir_black
" disable match parentheses hopefully speed up
" file loading
@@ -80,9 +75,9 @@ set visualbell " No beeping.
set noerrorbells " No beeping.
" Until i figure things out then ill switch the backup off
-" set nobackup " Don't make a backup before overwriting a file.
-" set nowritebackup " And again.
-" set noswapfile
+set nobackup " Don't make a backup before overwriting a file.
+set nowritebackup " And again.
+set noswapfile
" set directory=$HOME/.vim/tmp//,. " Keep swap files in one location
" Directories for swp files
set backup
@@ -131,11 +126,6 @@ vmap <s-tab> <gv
" Let leader key
let mapleader=","
-" Map escape to Ctrl-C
-" works anyway?
-"map <c-c> <esc>
-"map <C-[> <esc>
-
" switch buffers with leader leader
nnoremap <leader><leader> <c-^>
@@ -199,7 +189,7 @@ vmap <C-Down> ]egv
" Enable syntastic syntax checking
let g:syntastic_enable_signs=1
-let g:syntastic_quiet_warnings=1
+"let g:syntastic_quiet_warnings=1
" gist-vim defaults
if has("mac")
@@ -262,7 +252,7 @@ let g:EasyMotion_leader_key="<Leader>ss"
" Indent Guides. Set the color change percent higher
" since you can just switch them on and off might as well see clearly ;)
-let g:indent_guides_color_change_percent=20
+let g:indent_guides_color_change_percent=30
" Add some teaching/learning maps for now
" Regenerate tags
1  zsh/aliases
View
@@ -19,6 +19,7 @@ alias go="git checkout"
#rails
alias migrate='rake db:migrate && rake db:test:prepare'
+alias be='bundle exec'
alias brs='bundle exec rails s'
alias brc='bundle exec rails c'
364 zsh/bin/git-wtf
View
@@ -0,0 +1,364 @@
+#!/usr/bin/env ruby
+
+HELP = <<EOS
+git-wtf displays the state of your repository in a readable, easy-to-scan
+format. It's useful for getting a summary of how a branch relates to a remote
+server, and for wrangling many topic branches.
+
+git-wtf can show you:
+- How a branch relates to the remote repo, if it's a tracking branch.
+- How a branch relates to integration branches, if it's a feature branch.
+- How a branch relates to the feature branches, if it's an integration
+ branch.
+
+git-wtf is best used before a git push, or between a git fetch and a git
+merge. Be sure to set color.ui to auto or yes for maximum viewing pleasure.
+EOS
+
+KEY = <<EOS
+KEY:
+() branch only exists locally
+{} branch only exists on a remote repo
+[] branch exists locally and remotely
+
+x merge occurs both locally and remotely
+~ merge occurs only locally
+ (space) branch isn't merged in
+
+(It's possible for merges to occur remotely and not locally, of course, but
+that's a less common case and git-wtf currently doesn't display anything
+special for it.)
+EOS
+
+USAGE = <<EOS
+Usage: git wtf [branch+] [options]
+
+If [branch] is not specified, git-wtf will use the current branch. The possible
+[options] are:
+
+ -l, --long include author info and date for each commit
+ -a, --all show all branches across all remote repos, not just
+ those from origin
+ -A, --all-commits show all commits, not just the first 5
+ -s, --short don't show commits
+ -k, --key show key
+ -r, --relations show relation to features / integration branches
+ --dump-config print out current configuration and exit
+
+git-wtf uses some heuristics to determine which branches are integration
+branches, and which are feature branches. (Specifically, it assumes the
+integration branches are named "master", "next" and "edge".) If it guesses
+incorrectly, you will have to create a .git-wtfrc file.
+
+To start building a configuration file, run "git-wtf --dump-config >
+.git-wtfrc" and edit it. The config file is a YAML file that specifies the
+integration branches, any branches to ignore, and the max number of commits to
+display when --all-commits isn't used. git-wtf will look for a .git-wtfrc file
+starting in the current directory, and recursively up to the root.
+
+IMPORTANT NOTE: all local branches referenced in .git-wtfrc must be prefixed
+with heads/, e.g. "heads/master". Remote branches must be of the form
+remotes/<remote>/<branch>.
+EOS
+
+COPYRIGHT = <<EOS
+git-wtf Copyright 2008--2009 William Morgan <wmorgan at the masanjin dot nets>.
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the Free
+Software Foundation, either version 3 of the License, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+more details.
+
+You can find the GNU General Public License at: http://www.gnu.org/licenses/
+EOS
+
+require 'yaml'
+CONFIG_FN = ".git-wtfrc"
+
+class Numeric; def pluralize s; "#{to_s} #{s}" + (self != 1 ? "s" : "") end end
+
+if ARGV.delete("--help") || ARGV.delete("-h")
+ puts USAGE
+ exit
+end
+
+## poor man's trollop
+$long = ARGV.delete("--long") || ARGV.delete("-l")
+$short = ARGV.delete("--short") || ARGV.delete("-s")
+$all = ARGV.delete("--all") || ARGV.delete("-a")
+$all_commits = ARGV.delete("--all-commits") || ARGV.delete("-A")
+$dump_config = ARGV.delete("--dump-config")
+$key = ARGV.delete("--key") || ARGV.delete("-k")
+$show_relations = ARGV.delete("--relations") || ARGV.delete("-r")
+ARGV.each { |a| abort "Error: unknown argument #{a}." if a =~ /^--/ }
+
+## search up the path for a file
+def find_file fn
+ while true
+ return fn if File.exist? fn
+ fn2 = File.join("..", fn)
+ return nil if File.expand_path(fn2) == File.expand_path(fn)
+ fn = fn2
+ end
+end
+
+want_color = `git config color.wtf`
+want_color = `git config color.ui` if want_color.empty?
+$color = case want_color.chomp
+ when "true"; true
+ when "auto"; $stdout.tty?
+end
+
+def red s; $color ? "\033[31m#{s}\033[0m" : s end
+def green s; $color ? "\033[32m#{s}\033[0m" : s end
+def yellow s; $color ? "\033[33m#{s}\033[0m" : s end
+def cyan s; $color ? "\033[36m#{s}\033[0m" : s end
+def grey s; $color ? "\033[1;30m#{s}\033[0m" : s end
+def purple s; $color ? "\033[35m#{s}\033[0m" : s end
+
+## the set of commits in 'to' that aren't in 'from'.
+## if empty, 'to' has been merged into 'from'.
+def commits_between from, to
+ if $long
+ `git log --pretty=format:"- %s [#{yellow "%h"}] (#{purple "%ae"}; %ar)" #{from}..#{to}`
+ else
+ `git log --pretty=format:"- %s [#{yellow "%h"}]" #{from}..#{to}`
+ end.split(/[\r\n]+/)
+end
+
+def show_commits commits, prefix=" "
+ if commits.empty?
+ puts "#{prefix} none"
+ else
+ max = $all_commits ? commits.size : $config["max_commits"]
+ max -= 1 if max == commits.size - 1 # never show "and 1 more"
+ commits[0 ... max].each { |c| puts "#{prefix}#{c}" }
+ puts grey("#{prefix}... and #{commits.size - max} more (use -A to see all).") if commits.size > max
+ end
+end
+
+def ahead_behind_string ahead, behind
+ [ahead.empty? ? nil : "#{ahead.size.pluralize 'commit'} ahead",
+ behind.empty? ? nil : "#{behind.size.pluralize 'commit'} behind"].
+ compact.join("; ")
+end
+
+def widget merged_in, remote_only=false, local_only=false, local_only_merge=false
+ left, right = case
+ when remote_only; %w({ })
+ when local_only; %w{( )}
+ else %w([ ])
+ end
+ middle = case
+ when merged_in && local_only_merge; green("~")
+ when merged_in; green("x")
+ else " "
+ end
+ print left, middle, right
+end
+
+def show b
+ have_both = b[:local_branch] && b[:remote_branch]
+
+ pushc, pullc, oosync = if have_both
+ [x = commits_between(b[:remote_branch], b[:local_branch]),
+ y = commits_between(b[:local_branch], b[:remote_branch]),
+ !x.empty? && !y.empty?]
+ end
+
+ if b[:local_branch]
+ puts "Local branch: " + green(b[:local_branch].sub(/^heads\//, ""))
+
+ if have_both
+ if pushc.empty?
+ puts "#{widget true} in sync with remote"
+ else
+ action = oosync ? "push after rebase / merge" : "push"
+ puts "#{widget false} NOT in sync with remote (you should #{action})"
+ show_commits pushc unless $short
+ end
+ end
+ end
+
+ if b[:remote_branch]
+ puts "Remote branch: #{cyan b[:remote_branch]} (#{b[:remote_url]})"
+
+ if have_both
+ if pullc.empty?
+ puts "#{widget true} in sync with local"
+ else
+ action = pushc.empty? ? "merge" : "rebase / merge"
+ puts "#{widget false} NOT in sync with local (you should #{action})"
+ show_commits pullc unless $short
+ end
+ end
+ end
+
+ puts "\n#{red "WARNING"}: local and remote branches have diverged. A merge will occur unless you rebase." if oosync
+end
+
+def show_relations b, all_branches
+ ibs, fbs = all_branches.partition { |name, br| $config["integration-branches"].include?(br[:local_branch]) || $config["integration-branches"].include?(br[:remote_branch]) }
+ if $config["integration-branches"].include? b[:local_branch]
+ puts "\nFeature branches:" unless fbs.empty?
+ fbs.each do |name, br|
+ next if $config["ignore"].member?(br[:local_branch]) || $config["ignore"].member?(br[:remote_branch])
+ next if br[:ignore]
+ local_only = br[:remote_branch].nil?
+ remote_only = br[:local_branch].nil?
+ name = if local_only
+ purple br[:name]
+ elsif remote_only
+ cyan br[:name]
+ else
+ green br[:name]
+ end
+
+ ## for remote_only branches, we'll compute wrt the remote branch head. otherwise, we'll
+ ## use the local branch head.
+ head = remote_only ? br[:remote_branch] : br[:local_branch]
+
+ remote_ahead = b[:remote_branch] ? commits_between(b[:remote_branch], head) : []
+ local_ahead = b[:local_branch] ? commits_between(b[:local_branch], head) : []
+
+ if local_ahead.empty? && remote_ahead.empty?
+ puts "#{widget true, remote_only, local_only} #{name} #{local_only ? "(local-only) " : ""}is merged in"
+ elsif local_ahead.empty?
+ puts "#{widget true, remote_only, local_only, true} #{name} merged in (only locally)"
+ else
+ behind = commits_between head, (br[:local_branch] || br[:remote_branch])
+ ahead = remote_only ? remote_ahead : local_ahead
+ puts "#{widget false, remote_only, local_only} #{name} #{local_only ? "(local-only) " : ""}is NOT merged in (#{ahead_behind_string ahead, behind})"
+ show_commits ahead unless $short
+ end
+ end
+ else
+ puts "\nIntegration branches:" unless ibs.empty? # unlikely
+ ibs.sort_by { |v, br| v }.each do |v, br|
+ next if $config["ignore"].member?(br[:local_branch]) || $config["ignore"].member?(br[:remote_branch])
+ next if br[:ignore]
+ local_only = br[:remote_branch].nil?
+ remote_only = br[:local_branch].nil?
+ name = remote_only ? cyan(br[:name]) : green(br[:name])
+
+ ahead = commits_between v, (b[:local_branch] || b[:remote_branch])
+ if ahead.empty?
+ puts "#{widget true, local_only} merged into #{name}"
+ else
+ #behind = commits_between b[:local_branch], v
+ puts "#{widget false, local_only} NOT merged into #{name} (#{ahead.size.pluralize 'commit'} ahead)"
+ show_commits ahead unless $short
+ end
+ end
+ end
+end
+
+#### EXECUTION STARTS HERE ####
+
+## find config file and load it
+$config = { "integration-branches" => %w(heads/master heads/next heads/edge), "ignore" => [], "max_commits" => 5 }.merge begin
+ fn = find_file CONFIG_FN
+ if fn && (h = YAML::load_file(fn)) # yaml turns empty files into false
+ h["integration-branches"] ||= h["versions"] # support old nomenclature
+ h
+ else
+ {}
+ end
+end
+
+if $dump_config
+ puts $config.to_yaml
+ exit
+end
+
+## first, index registered remotes
+remotes = `git config --get-regexp ^remote\.\*\.url`.split(/[\r\n]+/).inject({}) do |hash, l|
+ l =~ /^remote\.(.+?)\.url (.+)$/ or next hash
+ hash[$1] ||= $2
+ hash
+end
+
+## next, index followed branches
+branches = `git config --get-regexp ^branch\.`.split(/[\r\n]+/).inject({}) do |hash, l|
+ case l
+ when /branch\.(.*?)\.remote (.+)/
+ name, remote = $1, $2
+
+ hash[name] ||= {}
+ hash[name].merge! :remote => remote, :remote_url => remotes[remote]
+ when /branch\.(.*?)\.merge ((refs\/)?heads\/)?(.+)/
+ name, remote_branch = $1, $4
+ hash[name] ||= {}
+ hash[name].merge! :remote_mergepoint => remote_branch
+ end
+ hash
+end
+
+## finally, index all branches
+remote_branches = {}
+`git show-ref`.split(/[\r\n]+/).each do |l|
+ sha1, ref = l.chomp.split " refs/"
+
+ if ref =~ /^heads\/(.+)$/ # local branch
+ name = $1
+ next if name == "HEAD"
+ branches[name] ||= {}
+ branches[name].merge! :name => name, :local_branch => ref
+ elsif ref =~ /^remotes\/(.+?)\/(.+)$/ # remote branch
+ remote, name = $1, $2
+ remote_branches["#{remote}/#{name}"] = true
+ next if name == "HEAD"
+ ignore = !($all || remote == "origin")
+
+ branch = name
+ if branches[name] && branches[name][:remote] == remote
+ # nothing
+ else
+ name = "#{remote}/#{branch}"
+ end
+
+ branches[name] ||= {}
+ branches[name].merge! :name => name, :remote => remote, :remote_branch => "#{remote}/#{branch}", :remote_url => remotes[remote], :ignore => ignore
+ end
+end
+
+## assemble remotes
+branches.each do |k, b|
+ next unless b[:remote] && b[:remote_mergepoint]
+ b[:remote_branch] = if b[:remote] == "."
+ b[:remote_mergepoint]
+ else
+ t = "#{b[:remote]}/#{b[:remote_mergepoint]}"
+ remote_branches[t] && t # only if it's still alive
+ end
+end
+
+show_dirty = ARGV.empty?
+targets = if ARGV.empty?
+ [`git symbolic-ref HEAD`.chomp.sub(/^refs\/heads\//, "")]
+else
+ ARGV.map { |x| x.sub(/^heads\//, "") }
+end.map { |t| branches[t] or abort "Error: can't find branch #{t.inspect}." }
+
+targets.each do |t|
+ show t
+ show_relations t, branches if $show_relations || t[:remote_branch].nil?
+end
+
+modified = show_dirty && `git ls-files -m` != ""
+uncommitted = show_dirty && `git diff-index --cached HEAD` != ""
+
+if $key
+ puts
+ puts KEY
+end
+
+puts if modified || uncommitted
+puts "#{red "NOTE"}: working directory contains modified files." if modified
+puts "#{red "NOTE"}: staging area contains staged but uncommitted files." if uncommitted
+
+# the end!
13 zsh/bin/gitfind
View
@@ -0,0 +1,13 @@
+#!/bin/bash
+# original credit to http://stackoverflow.com/questions/372506/how-can-i-search-git-branches-for-a-file-or-directory/372654#372654
+# usage: "gitfind.sh <regex>"
+
+LOC=refs/remotes/origin
+#LOC=refs/heads # to search local branches only
+
+for branch in `git for-each-ref --format="%(refname)" $LOC`; do
+ found=$(git ls-tree -r --name-only $branch | grep "$1")
+ if [ $? -eq 0 ]; then
+ echo ${branch#$LOC/}:; echo " $found"
+ fi
+done
2  zsh/correction
View
@@ -12,3 +12,5 @@ alias npm='nocorrect npm'
alias bundler='nocorrect bundler'
alias pry='nocorrect pry'
alias tree='nocorrect tree'
+alias cheat='nocorrect cheat'
+alias rspec='nocorrect rspec'
2  zshenv
View
@@ -1,3 +1,5 @@
+# shortcut to this $ZSH path is $ZSH
+export ZSH=~/.zsh
# PATH and EXPORT VARIABLES
export LESS=-RFX
export SHELL=/bin/zsh
9 zshrc
View
@@ -1,6 +1,3 @@
-# shortcut to this $ZSH path is $ZSH
-export ZSH=~/.zsh
-
. $ZSH/config
. $ZSH/prompt
. $ZSH/aliases
@@ -17,6 +14,12 @@ set -o emacs # or vi if you prefer
# keep this here as a fix for rake
alias rake='noglob rake'
+# http://talkings.org/post/5236392664/zsh-and-slow-git-completion
+# superfly tnt git autocomplete
+__git_files () {
+ _wanted files expl 'local files' _files
+}
+
# print current directory to title bar
# osx lion now uses that when opening new
# terminal window or tab

No commit comments for this range

Something went wrong with that request. Please try again.