Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add my scripts in bin/*

  • Loading branch information...
commit b5058973bf28f6771b2eed4357db71a0c877bef1 1 parent 277b38d
@mislav authored
View
6 .gitignore
@@ -0,0 +1,6 @@
+bin/AMSTracker
+bin/asciidoc
+bin/gitx
+bin/growlnotify
+bin/hanna
+bin/mate
View
9 bin/crlf
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+ARGV.each do |file|
+ next unless file =~ /\.\w{2,4}$/
+ text = File.read(file)
+ if text[0,3] == "\357\273\277" or text.index("\r\n")
+ File.open(file, 'w') { |f| f << text.sub("\357\273\277", '').gsub("\r\n", "\n") }
+ puts "#{file} cleansed."
+ end
+end
View
24 bin/each-git
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+# for each git repo in a subdirectory ...
+dirs = Dir['**/.git'].map { |gd| File.dirname(gd) }
+
+def prompt
+ print ">> "
+ gets
+end
+
+# ... execute a command given on STDIN
+while command = prompt
+ dirs.each do |dir|
+ begin
+ Dir.chdir(dir) do
+ puts "~ #{dir}:"
+ system command
+ end
+ rescue Errno::ENOENT => e
+ $stderr.puts e.message
+ end
+ end
+end
+
+# (press Ctrl+D to break out of the loop)
View
75 bin/gist
@@ -0,0 +1,75 @@
+#!/usr/bin/env ruby
+
+=begin
+
+INSTALL:
+
+ curl http://github.com/defunkt/gist/tree/master%2Fgist.rb?raw=true > gist &&
+ chmod 755 gist &&
+ sudo mv gist /usr/local/bin/gist
+
+USE:
+
+ cat file.txt | gist
+ echo hi | gist
+ gist 1234 > something.txt
+
+=end
+
+require 'open-uri'
+require 'net/http'
+
+module Gist
+ extend self
+
+ @@gist_url = 'http://gist.github.com/%d.txt'
+ @@gist_regexp = Regexp.new('http://gist.github.com/(\d+)')
+
+ def read(gist_id)
+ return help if gist_id == '-h' || gist_id.nil? || gist_id[/help/]
+ open(@@gist_url % gist_id).read
+ end
+
+ def write(content)
+ url = URI.parse('http://gist.github.com/gists')
+ req = Net::HTTP.post_form(url, data(nil, nil, content))
+
+ copy req.body[@@gist_regexp]
+ end
+
+ def help
+ "USE:\n " + File.read(__FILE__).match(/USE:(.+?)=end/m)[1].strip
+ end
+
+private
+ def copy(content)
+ return content if `which pbcopy`.strip == ''
+
+ IO.popen('pbcopy', 'r+') do |clipboard|
+ clipboard.puts content
+ end
+
+ content
+ end
+
+ def data(name, ext, content)
+ return {
+ 'file_ext[gistfile1]' => ext,
+ 'file_name[gistfile1]' => name,
+ 'file_contents[gistfile1]' => content
+ }.merge(auth)
+ end
+
+ def auth
+ user = `git config --global github.user`.strip
+ token = `git config --global github.token`.strip
+
+ user.empty? ? {} : { :login => user, :token => token }
+ end
+end
+
+if $stdin.tty?
+ puts Gist.read(ARGV.first)
+else
+ puts Gist.write($stdin.read)
+end
View
8 bin/git-track
@@ -0,0 +1,8 @@
+#!/bin/sh
+branch=$(git branch 2>/dev/null | grep ^\*)
+[ x$1 != x ] && tracking=$1 || tracking=${branch/* /}
+
+git config branch.$tracking.remote origin
+git config branch.$tracking.merge refs/heads/$tracking
+
+echo "tracking origin/$tracking"
View
69 bin/mvim
@@ -0,0 +1,69 @@
+#!/bin/sh
+#
+# This shell script passes all its arguments to the binary inside the
+# MacVim.app application bundle. If you make links to this script as view,
+# gvim, etc., then it will peek at the name used to call it and set options
+# appropriately.
+#
+# Based on a script by Wout Mertens and suggestions from Laurent Bihanic. This
+# version is the fault of Benji Fisher, 16 May 2005 (with modifications by Nico
+# Weber and Bjorn Winckler, Aug 13 2007).
+# First, check "All the Usual Suspects" for the location of the Vim.app bundle.
+# You can short-circuit this by setting the VIM_APP_DIR environment variable
+# or by un-commenting and editing the following line:
+# VIM_APP_DIR=/Applications
+
+if [ -z "$VIM_APP_DIR" ]
+then
+ myDir="`dirname "$0"`"
+ myAppDir="$myDir/../Applications"
+ for i in ~/Applications ~/Applications/vim $myDir $myDir/vim $myAppDir $myAppDir/vim /Applications /Applications/vim /Applications/Utilities /Applications/Utilities/vim; do
+ if [ -x "$i/MacVim.app" ]; then
+ VIM_APP_DIR="$i"
+ break
+ fi
+ done
+fi
+if [ -z "$VIM_APP_DIR" ]
+then
+ echo "Sorry, cannot find MacVim.app. Try setting the VIM_APP_DIR environment variable to the directory containing MacVim.app."
+ exit 1
+fi
+binary="$VIM_APP_DIR/MacVim.app/Contents/MacOS/Vim"
+
+# Next, peek at the name used to invoke this script, and set options
+# accordingly.
+
+name="`basename "$0"`"
+gui=
+opts=
+
+# GUI mode, implies forking
+case "$name" in m*|g*|rg*) gui=true ;; esac
+
+# Restricted mode
+case "$name" in r*) opts="$opts -Z";; esac
+
+# vimdiff and view
+case "$name" in
+ *vimdiff)
+ opts="$opts -dO"
+ ;;
+ *view)
+ opts="$opts -R"
+ ;;
+esac
+
+# Last step: fire up vim.
+# The program should fork by default when started in GUI mode, but it does
+# not; we work around this when this script is invoked as "gvim" or "rgview"
+# etc., but not when it is invoked as "vim -g".
+if [ "$gui" ]; then
+ # Note: this isn't perfect, because any error output goes to the
+ # terminal instead of the console log.
+ # But if you use open instead, you will need to fully qualify the
+ # path names for any filenames you specify, which is hard.
+ exec "$binary" -g $opts ${1:+"$@"}
+else
+ exec "$binary" $opts ${1:+"$@"}
+fi
View
2  bin/nub
@@ -0,0 +1,2 @@
+#!/bin/sh
+open -b com.alternateidea.rubycocoa.GitNubApp .
Please sign in to comment.
Something went wrong with that request. Please try again.