Permalink
Browse files

~/bin

  • Loading branch information...
1 parent ce26822 commit d3b9d746b8acec25aa9e1a3e78614f278ad4d097 @andersonfreitas committed Jul 30, 2012
Showing with 501 additions and 0 deletions.
  1. +8 −0 bin/git-current-branch
  2. +49 −0 bin/git-cwd-info.rb
  3. +74 −0 bin/highlight
  4. +10 −0 bin/htmlgrep
  5. +15 −0 bin/lyrics
  6. +72 −0 bin/mvim
  7. +269 −0 bin/offset.pl
  8. +4 −0 bin/wkhtmltopdf.dump
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+# Print the current Git branch.
+#
+# AUTHOR:
+# Geoffrey Grosenbach http://peepcode.com
+
+git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||'
View
@@ -0,0 +1,49 @@
+#!/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 current-branch`.chomp
+end
+
+def git_head_commit_id
+ `git rev-parse --short HEAD 2>/dev/null`.strip
+end
+
+def git_cwd_dirty
+ "" 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 " #{git_parse_branch} #{git_head_commit_id}#{rebasing_etc}#{git_cwd_dirty}"
+end
View
@@ -0,0 +1,74 @@
+#!/bin/bash
+#
+# Simple colorize for bash by means of sed
+#
+# Copyright 2008 by Andreas Schamanek <andreas@schamanek.net>
+# GPL licensed (see end of file) * Use at your own risk!
+#
+# Usage examples:
+# tail -f somemaillog | mycolorize white '^From: .*' bell
+# tail -f somemaillog | mycolorize white '^From: \/.*' green 'Folder: .*'
+#
+# Notes:
+# Regular expressions need to be suitable for _sed_
+# Slashes / need no escaping (we use ^A as delimiter)
+# \/ splits the coloring (similar to procmailrc. Matches behind get color.
+# Even "white 'for \/\(her\|him\).*$'" works :) Surprisingly ;)
+
+# For the colors see tput(1) and terminfo(5)
+red=$(tput bold;tput setaf 1) # bright red text
+green=$(tput setaf 2) # dim green text
+yellow=$(tput bold;tput setaf 3) # bright yellow text
+fawn=$(tput setaf 3) ; beige=$fawn # dark yellow text
+blue=$(tput bold;tput setaf 4) # blue text
+purple=$(tput setaf 5) ; magenta=$purple # magenta text
+pink=$(tput bold;tput setaf 5) # bright magenta text
+cyan=$(tput bold;tput setaf 6) # bright cyan text
+gray=$(tput setaf 8) # dim white text
+white=$(tput bold;tput setaf 7) # bright white text
+normal=$(tput sgr0) # normal text
+
+bell=$(tput bel) # bell/beep
+
+# produce separator character ^A (for _sed_)
+A=$(echo | tr '\012' '\001')
+
+# compile all rules given at command line to 1 set of rules for SED
+while [ "/$1/" != '//' ] ; do
+ c1=''; re=''; beep=''
+ c1=$1 ; re="$2" ; shift 2
+ # if a beep is requested in the optional 3rd parameter set $beep
+ [ "/$1/" != '//' ] && [[ ( "$1" = 'bell' || "$1" = 'beep' ) ]] \
+ && beep=$bell && shift
+ # if the regular expression includes \/ we split the substitution
+ if [ "/${re/*\\\/*/}/" = '//' ] ; then
+ re="${re/\\\//\)\(}"
+ sedrules="$sedrules;s$A\($re\)$A\1${!c1}\2$beep$normal${A}g"
+ else
+ sedrules="$sedrules;s$A\($re\)$A${!c1}\1$beep$normal${A}g"
+ fi
+
+done
+
+# call sed to do the main job
+sed -e "$sedrules"
+
+exit
+
+# License
+#
+# This script 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 2 of the License, or
+# (at your option) any later version.
+#
+# This script 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 should have received a copy of the GNU General Public License
+# along with this script; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+# Boston, MA 02111-1307 USA
+
View
@@ -0,0 +1,10 @@
+#!/Users/andersonfreitas/.rvm/bin/rvm-auto-ruby
+
+require 'rubygems'
+require 'hpricot'
+require 'open-uri'
+
+file = open(ARGV[1]) if ARGV[1]
+file ||= STDIN
+doc = Hpricot(file)
+puts doc / ARGV[0]
View
@@ -0,0 +1,15 @@
+#!/bin/bash
+#
+# lyrics.sh
+#
+# A fine piece of work by @febuiles
+# https://gist.github.com/1549979
+
+artist_name=`arch -i386 osascript -e'tell application "iTunes"' -e'get artist of current track' -e'end tell'`
+song_title=`arch -i386 osascript -e'tell application "iTunes"' -e'get name of current track' -e'end tell'`
+
+artist=`echo $artist_name | sed "s/[[:space:]]/%20/g"`
+title=`echo $song_title | sed "s/[[:space:]]/%20/g"`
+song=`curl -s "http://makeitpersonal.co/lyrics?artist=$artist&title=$title"`
+
+echo -e "$artist_name - $song_title\n$song" | less
View
@@ -0,0 +1,72 @@
+#!/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*|rm*|rg*) gui=true ;; esac
+
+# Restricted mode
+case "$name" in r*) opts="$opts -Z";; esac
+
+# vimdiff, view, and ex mode
+case "$name" in
+ *vimdiff)
+ opts="$opts -dO"
+ ;;
+ *view)
+ opts="$opts -R"
+ ;;
+ *ex)
+ opts="$opts -e"
+ ;;
+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
Oops, something went wrong.

0 comments on commit d3b9d74

Please sign in to comment.